ESYAE-imza Kütüphaneleri

User Tools

Site Tools


en:esya:log

Log Records

ESYA JAVA API uses SLF4J API for logging purposes. SLF4J provides capability to use several existing logging solutions rather than providing a single standalone log framework.

To record logs, firstly a logging API supported by SLF4J must be used two examples of which are JUL (java.util.logging) and LOG4J.You can also use SLF4J's own API for logging. To use JUL, corresponding plug-in (slf4j-jdk14-<version>.jar) must be used. For LOG4J, the required plug-in is (slf4j-log4j12-<version>.jar) and LOG4J library files must also be added to the project. The configuration of logging must be performed by the employed API's settings.

As for LOG4J, you can specify the configuration file by PropertyConfigurator.configure(“file_name”) function call.

 
#PropertConfigurator.configure("log4j.properties"); 
# Set root logger level to DEBUG and its appender to console,rolling,lf5rolling 
log4j.rootLogger=debug,rolling 
# BEGIN APPENDER: CONSOLE APPENDER (console) 
log4j.appender.console=org.apache.log4j.ConsoleAppender 
log4j.appender.console.layout=org.apache.log4j.PatternLayout 
log4j.appender.console.layout.ConversionPattern=%p %d{DATE} %c{2} (%F:%M:%L) - %m%n 
# END APPENDER: CONSOLE APPENDER (console) 
# BEGIN APPENDER: ROLLING FILE APPENDER (rolling) 
log4j.appender.rolling=org.apache.log4j.RollingFileAppender 
log4j.appender.rolling.File=ESYA_API.log 
log4j.appender.rolling.MaxFileSize=50MB 
log4j.appender.rolling.MaxBackupIndex=20 
log4j.appender.rolling.layout=org.apache.log4j.PatternLayout 
log4j.appender.rolling.layout.ConversionPattern=%p %d{DATE} %c{2} (%F:%M:%L) - %m%n 
# END APPENDER: ROLLING FILE APPENDER (rolling)
To configure JUL, the file “logging.properties” in the “lib” folder of the current JRE must be updated properly

 
handlers= java.util.logging.ConsoleHandler
.level= FINE
java.util.logging.FileHandler.pattern = %h/java%u.log
java.util.logging.FileHandler.limit = 50000
java.util.logging.FileHandler.count = 1
java.util.logging.FileHandler.formatter = java.util.logging.XMLFormatter
java.util.logging.ConsoleHandler.level = FINE
java.util.logging.ConsoleHandler.formatter = java.util.logging.SimpleFormatter
com.xyz.foo.level = FINE

ESYA C# API uses LOG4NET API which can be configured by XmlConfigurator.Configure(new FileInfo(“file_name”)) function call.

 
<log4net> 
<!-- A1 is set to be a ConsoleAppender --> 
<appender name="A1" type="log4net.Appender.ConsoleAppender"> 
<!-- A1 uses PatternLayout --> 
<layout type="log4net.Layout.PatternLayout"> 
<conversionPattern value="%-4timestamp [%thread] %-5level %logger %ndc - %message%newline" /> 
</layout> 
</appender> 
<appender name="FileAppender" type="log4net.Appender.FileAppender"> 
<file value="ESYA_API.log" /> 
<appendToFile value="true" /> 
<lockingModel type="log4net.Appender.FileAppender+MinimalLock" /> 
<layout type="log4net.Layout.PatternLayout"> 
<conversionPattern value="%date [%thread] %level %logger %ndc(%F:%L) - %message%newline" /> 
</layout> 
</appender> 
<!-- Set root logger level to DEBUG and its only appender to A1 --> 
<root> 
<level value="ALL" /> 
<appender-ref ref="FileAppender" /> 
</root> 
</log4net> 

en/esya/log.txt · Son değiştirilme: 2013/07/24 06:15 Değiştiren: Dindar Öz