快轉到主要內容

文章

2015


log4net Action Log 設定

·4 分鐘

我之前設定網站執行的 Action Log 的一個記錄,有些東西都是拼拼湊湊出來的,並不見得是最佳版本

log4net 設定檔

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
<?xml version="1.0" encoding="utf-8" ?>
<log4net>
    <root>
        <level value="DEBUG" />
        <appender-ref ref="stdout" />
        <appender-ref ref="ActionLogRollingFile" />
    </root>
    <appender name="ActionLogRollingFile" type="log4net.Appender.RollingFileAppender">
        <file type="log4net.Util.PatternString" value="action.log" />
        <appendToFile value="true" />
        <encoding value="utf-8" />
        <maxSizeRollBackups value="30" />
        <rollingStyle value="Date" />
        <datePattern value="'.'yyyy-MM-dd" />
        <layout type="log4net.Layout.PatternLayout">
            <conversionPattern value="(%date{HH:mm:ss,fff}) [%t] - %u %5property{Duration} %property{StatusCode} %6property{Method} %property{Uri} %m%n " />
        </layout>
        <filter type="log4net.Filter.LoggerMatchFilter">
            <acceptOnMatch value="true" />
            <LoggerToMatch value="Sample.Web.Filters.WebApiActionFilter" />
        </filter>

        <filter type="log4net.Filter.DenyAllFilter" />
    </appender>
</log4net>

其中要注意的是

  • log4net.Filter.LoggerMatchFilter: 用來設定特定的 class 記錄才使用這個 Appender
    • acceptOnMatch: 這個設定有點像是 blacklist/whitelist,true 表示有 match 才是,相當於 whitelist
    • LoggerToMatch: 設定要篩選的類別名稱
  • log4net.Filter.DenyAllFilter: 篩選掉其他的 Log,不會在這個 Appender 裡面記錄

JWT

·2 分鐘

OAuth2 現在已經很多的網站都有實作了,像是 Twitter, Google, Facebook, Github 等網站本身都有支援 OAuth2 的驗證與授權機制

最近因為專案需求,特地去研究了一下有關 Web API 做驗證授權的機制,看到網路上有很多的範例,在講解 AngularJS SPA 的登入作法,想說可以把類似的機制放到 RESTful Service 的驗證上面

2014


Docker service behind proxy - Ubuntu

·1 分鐘

編輯 /etc/default/docker
把以下 export http_proxy 的那一行 unmark, 然後改成你的 proxy 設定

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
# Docker Upstart and SysVinit configuration file

# Customize location of Docker binary (especially for development testing).
#DOCKER="/usr/local/bin/docker"

# Use DOCKER_OPTS to modify the daemon startup options.
#DOCKER_OPTS="--dns 8.8.8.8 --dns 8.8.4.4"

# If you need Docker to use an HTTP proxy, it can also be specified here.
export http_proxy="http://127.0.0.1:3128/"

# This is also a handy place to tweak where Docker's temporary files go.
#export TMPDIR="/mnt/bigdrive/docker-tmp"

重新啟動 docker service — service docker restart

Git-Tf 協同作業,Git 的一些小設定

·1 分鐘

本身有用 Windows, Mac 在開發系統,我其實是偏好在 Mac 編輯,因為我喜歡 Sublime Text !!!

不過,在 Windows 中用 Visual Studio 2013, 公司內部是規定使用 TFS (老實說我不是很喜歡,不過整個團隊以及公司都是這樣,也不得不用~)

有些時候,不想使用笨重的 VS2013,像是開發 Web Project,我還是喜歡用 Sublime Text 編輯,像是 javascript/html 都有不錯的開發經驗~ 所以只好用 git-tf 來做界接~