-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
- Loading branch information
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
<?xml version="1.0" encoding="utf-8" ?> | ||
<configuration> | ||
<!-- Register a section handler for the log4net section --> | ||
<configSections> | ||
<section name="log4net" type="System.Configuration.IgnoreSectionHandler" /> | ||
</configSections> | ||
|
||
<appSettings> | ||
<!-- To enable internal log4net logging specify the following appSettings key --> | ||
<!-- <add key="log4net.Internal.Debug" value="true"/> --> | ||
</appSettings> | ||
|
||
<!-- This section contains the log4net configuration settings --> | ||
<log4net> | ||
<!-- Define some output appenders --> | ||
<appender name="LogFileAppender" type="log4net.Appender.FileAppender"> | ||
<file value="log-file.txt" /> | ||
<appendToFile value="true" /> | ||
<layout type="log4net.Layout.PatternLayout"> | ||
<header value="FILE HEADER " /> | ||
<footer value="FILE FOOTER " /> | ||
<conversionPattern value="%date [%thread] %-5level %logger (%property{log4net:HostName}) [%ndc] - %message%newline" /> | ||
</layout> | ||
</appender> | ||
|
||
<!-- Setup the root category, add the appenders and set the default level --> | ||
<root> | ||
<level value="DEBUG" /> | ||
<appender-ref ref="LogFileAppender" /> | ||
</root> | ||
</log4net> | ||
|
||
|
||
<system.runtime.remoting> | ||
<application name="Log4netRemotingServer"> | ||
<!-- We need to define the remoting channels on which we will publish | ||
the remote logging sink. --> | ||
<channels> | ||
<channel displayName="Server Channel" ref="tcp server" port="7070" /> | ||
</channels> | ||
</application> | ||
</system.runtime.remoting> | ||
</configuration> |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
using System; | ||
using log4net; | ||
|
||
public static class ILogExtentions | ||
{ | ||
private static log4net.ILog log = | ||
log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); | ||
|
||
private static void usage() | ||
{ | ||
log.Debug("usage"); | ||
} | ||
|
||
public static void Trace(this ILog log, string message, Exception exception) | ||
{ | ||
log.Logger.Log(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType, | ||
log4net.Core.Level.Trace, message, exception); | ||
} | ||
|
||
public static void Trace(this ILog log, string message) | ||
{ | ||
log.Trace(message, null); | ||
} | ||
|
||
public static void Verbose(this ILog log, string message, Exception exception) | ||
{ | ||
log.Logger.Log(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType, | ||
log4net.Core.Level.Verbose, message, exception); | ||
} | ||
|
||
public static void Verbose(this ILog log, string message) | ||
{ | ||
log.Verbose(message, null); | ||
} | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,121 @@ | ||
<?xml version="1.0" encoding="utf-8" ?> | ||
<configuration> | ||
<configSections> | ||
<section name="log4net" type="System.Configuration.IgnoreSectionHandler"/> | ||
</configSections> | ||
<appSettings> | ||
</appSettings> | ||
<log4net> | ||
<!--定义输出到文件中--> | ||
<appender name="RollingLogFileAppender" type="log4net.Appender.RollingFileAppender"> | ||
<!--1. 文件路径,如果RollingStyle为Composite或Date,则这里设置为目录,文件名在DatePattern里设置,其他则这里要有文件名。已经扩展支持虚拟目录--> | ||
<file value="Assets\Log\Editor\" /> | ||
<!--2. 创建新文件的方式,可选为Size(按文件大小),Date(按日期),Once(每启动一次创建一个文件),Composite(按日期及文件大小),默认为Composite--> | ||
<rollingStyle value="Composite" /> | ||
<!--3. 当RollingStyle为Composite或Date,这里设置文件名格式--> | ||
<datePattern value='yyyy-MM-dd".log"' /> | ||
<!--4. true/false,默认为true。为true时,RollingStyler的date值将无效。且为true时,需要在file里指定文件名,所有日志都会记录在这个文件里。--> | ||
<staticLogFileName value="false" /> | ||
<!--5. 当rollingStyle为Composite或Size,这里设置最大文件大小(可以KB,MB,GB为单位,默认为字节)--> | ||
<maximumFileSize value="1MB" /> | ||
<!--6. 默认值为-1。当文件超过MaximumFileSize的大小时,如果要创建新的文件来存储日志,会根据CountDirection的值来重命名文件。 | ||
大于-1的值时,file里指定的文件名会依次加上.0,.1,.2递增。 | ||
当等于或小于-1时,创建依赖于MaxSizeRollBackups参数值,创建备份日志数。--> | ||
<countDirection value="-1" /> | ||
<!--7. 备份日志数目,默认为0。在CountDirection为负数时有效。--> | ||
<maxSizeRollBackups value="-1" /> | ||
<!--8. true/false,默认为true。当文件存在时,是否在原文件上追加内容。--> | ||
<appendToFile value="true" /> | ||
|
||
<layout type="log4net.Layout.PatternLayout"> | ||
<!-- 日志起始输出 --> | ||
<header value="-----------程序开始运行----------- | ||
" /> | ||
<!-- 日志结束输出 --> | ||
<footer value="-----------程序结束运行----------- | ||
" /> | ||
<conversionPattern value="%date [%thread] %-5level [%ndc] - %message%newline" /> | ||
<conversionPattern value="记录时间:%date 线程ID:[%thread] 日志级别:%-5level 出错类:%logger property:[%property{NDC}] - 错误描述:%message%newline" /> | ||
</layout> | ||
</appender> | ||
<!--定义输出到控制台命令行中--> | ||
<appender name="ConsoleAppender" type="log4net.Appender.ConsoleAppender"> | ||
<layout type="log4net.Layout.PatternLayout"> | ||
<conversionPattern value="%date [%thread] %-5level %logger [%property{NDC}] - %message%newline" /> | ||
</layout> | ||
</appender> | ||
<!--定义输出到windows事件中--> | ||
<appender name="EventLogAppender" type="log4net.Appender.EventLogAppender"> | ||
<layout type="log4net.Layout.PatternLayout"> | ||
<conversionPattern value="%date [%thread] %-5level %logger [%property{NDC}] - %message%newline" /> | ||
</layout> | ||
</appender> | ||
<!--定义输出到数据库中,这里举例输出到Access数据库中,数据库为C盘的log4net.mdb--> | ||
<appender name="AdoNetAppender_Access" type="log4net.Appender.AdoNetAppender"> | ||
<connectionString value="Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:log4net.mdb" /> | ||
<commandText value="INSERT INTO LogDetails ([LogDate],[Thread],[Level],[Logger],[Message]) VALUES (@logDate, @thread, @logLevel, @logger,@message)" /> | ||
<!--定义各个参数--> | ||
<parameter> | ||
<parameterName value="@logDate" /> | ||
<dbType value="String" /> | ||
<size value="240" /> | ||
<layout type="log4net.Layout.PatternLayout"> | ||
<conversionPattern value="%date" /> | ||
</layout> | ||
</parameter> | ||
<parameter> | ||
<parameterName value="@thread" /> | ||
<dbType value="String" /> | ||
<size value="240" /> | ||
<layout type="log4net.Layout.PatternLayout"> | ||
<conversionPattern value="%thread" /> | ||
</layout> | ||
</parameter> | ||
<parameter> | ||
<parameterName value="@logLevel" /> | ||
<dbType value="String" /> | ||
<size value="240" /> | ||
<layout type="log4net.Layout.PatternLayout"> | ||
<conversionPattern value="%level" /> | ||
</layout> | ||
</parameter> | ||
<parameter> | ||
<parameterName value="@logger" /> | ||
<dbType value="String" /> | ||
<size value="240" /> | ||
<layout type="log4net.Layout.PatternLayout"> | ||
<conversionPattern value="%logger" /> | ||
</layout> | ||
</parameter> | ||
<parameter> | ||
<parameterName value="@message" /> | ||
<dbType value="String" /> | ||
<size value="240" /> | ||
<layout type="log4net.Layout.PatternLayout"> | ||
<conversionPattern value="%message" /> | ||
</layout> | ||
</parameter> | ||
</appender> | ||
<!--定义日志的输出媒介,下面定义日志以四种方式输出。也可以下面的按照一种类型或其他类型输出。--> | ||
<root> | ||
<!-- 记录哪个级别以上的日志: OFF->FATAL->ERROR->WARN->INFO->DEBUG/ALL --> | ||
<level value="ALL" /> | ||
<!--文件形式记录日志--> | ||
<appender-ref ref="RollingLogFileAppender" /> | ||
<!--控制台控制显示日志--> | ||
<appender-ref ref="ConsoleAppender" /> | ||
<!--Windows事件日志--> | ||
<appender-ref ref="EventLogAppender" /> | ||
<!-- 如果不启用相应的日志记录,可以通过这种方式注释掉 | ||
<appender-ref ref="AdoNetAppender_Access" /> | ||
--> | ||
<!--Udp控制显示日志log2console程序--> | ||
<appender-ref ref="udp"/> | ||
</root> | ||
<appender name="udp" type="log4net.Appender.UdpAppender"> | ||
<remoteAddress value="127.0.0.1" /> | ||
<remotePort value="7071" /> | ||
<layout type="log4net.Layout.XmlLayoutSchemaLog4j" /> | ||
</appender> | ||
</log4net> | ||
</configuration> |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.