2017-01-17 5 views
0

私はc#にクラスライブラリプロジェクトを作成し、log4netを使用してそのプロジェクトでロギングを有効にしたいとします。しかし、log4netの設定が機能していないので、ログインを有効にするためのコンソールプロジェクトが必要であることを示しています。ログインクラスライブラリプロジェクトを有効にする

ホストアプリケーションを使用せずにクラスライブラリプロジェクトでlog4netを設定する方法はありますか?あなたのdllのロギングを開始

+1

クラスライブラリはどのようにホストアプリケーションなしでも実行できますか? – David

答えて

0

2つの方法:DLLがロードされたとき

// Configure log4net using the .config file 
[assembly: log4net.Config.XmlConfigurator(Watch=true)] 
// This will cause log4net to look for a configuration file 
// called TestApp.exe.config in the application base 
// directory (i.e. the directory containing TestApp.exe) 
// The config file will be watched for changes. 

// Configure log4net using the .log4net file 
[assembly: log4net.Config.XmlConfigurator(ConfigFileExtension="log4net",Watch=true)] 
// This will cause log4net to look for a configuration file 
// called TestApp.exe.log4net in the application base 
// directory (i.e. the directory containing TestApp.exe) 
// The config file will be watched for changes. 

は両方の設定ファイルをロードします。

関連する問題