Asp.net 如何自定义loggingConfiguration的格式化程序?
我不熟悉EnterpriseLibrary.Logging。在web.config的loggingConfiguration下,我们有以下格式化程序:Asp.net 如何自定义loggingConfiguration的格式化程序?,asp.net,logging,exception-handling,enterprise-library,Asp.net,Logging,Exception Handling,Enterprise Library,我不熟悉EnterpriseLibrary.Logging。在web.config的loggingConfiguration下,我们有以下格式化程序: <formatters> <add name="Default Formatter" template="
Timestamp: {timestamp(local)}

Message: {message}

Category: {categ
<formatters>
<add name="Default Formatter" template="
Timestamp: {timestamp(local)}

Message: {message}

Category: {category}

Priority: {priority}

EventId: {eventid}

Severity: {severity}

Title:{title}

Machine: {machine}

Application Domain: {appDomain}

Process Id: {processId}

Process Name: {processName}

Win32 Thread Id: {win32ThreadId}

Thread Name: {threadName}

User Name: {userName}

 extended Properties: {dictionary({key} - {value}
)}"
type="Microsoft.Practices.EnterpriseLibrary.Logging.Formatters.TextFormatter, Microsoft.Practices.EnterpriseLibrary.Logging, Version=4.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
<add name="DBA Formatter" template="
Timestamp: {timestamp(local)}

Message: {message}

Category: {category}

Priority: {priority}

EventId: {eventid}

Severity: {severity}

Title:{title}

Machine: {machine}

Extended Properties: {dictionary({key} - {value}
)}"
type="Microsoft.Practices.EnterpriseLibrary.Logging.Formatters.TextFormatter, Microsoft.Practices.EnterpriseLibrary.Logging, Version=4.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
</formatters>
在代码隐藏中,我们只将消息设置为LogEntry。我想知道其他参数是如何设置的,例如时间戳、类别、优先级等。我已经添加了用户名,但不起作用。有人能帮我解释一下吗?这是微软关于这些参数的文章:。它讨论了可以在格式化程序中插入的各种标记 “用户名”不是预定义的令牌之一。但您可以(可能)使用LogEntry的ExtendedProperties属性来解决这个问题:
LogEntry le = new LogEntry();
le.ExtendedProperties.Add("username", "jsmith");