2
我想注入一個類型的信息到日誌呼叫只有一個呼叫,像我如何注入屬性在log4net的
public sealed class Logger
{
private readonly log4net.ILog _logger;
public Logger()
{
// somehow assing this._logger ... doesn't matter actually
}
public void Info<T>(string message)
{
if (!this._logger.IsInfoEnabled)
{
return;
}
var typeOfT = typeof (T);
var typeName = typeOfT.FullName;
// how to set a property here, only for this one single call
// which i can reference in the config
this._logger.Info(message);
}
}
註釋清楚:在某些時候,我想只爲這個特定的調用注入我的泛型參數的FullName
。
我使用log4net的1.2.11.0