View RSS Feed

My Java Tips file

Rate this Entry
by , 11-03-2011 at 12:34 PM (2243 Views) file is a configuration file (not in XML format). If you have a stand alone application, then should be in the directory where you issued the java command. In case of web application (JSP/Servlet), place at /WEB-INF/classes/.

A sample properties file is given below:

log4j.appender.stdout=org.apache.log4j.ConsoleAppe nder
log4j.appender.stdout.layout=org.apache.log4j.Patt ernLayout
log4j.appender.stdout.layout.ConversionPattern=[%d{MMM dd HH:mm:ss}] %-5p (%F:%L) - %m%n
log4j.appender.FILE.file=C:\Log4J\src\tmp\logs \log.txt
log4j.appender.FILE.layout=org.apache.log4j.Patter nLayout
log4j.appender.FILE.layout.ConversionPattern=[%d{MMM dd HH:mm:ss}] %-5p (%F:%L) - %m%n
log4j.rootLogger=debug, FILE,stdout

We have used only two appenders (ConsoleAppender and FileAppender)in the example above. All the possible appender options are:

AppenderSkeleton, AsyncAppender, ConsoleAppender, DailyRollingFileAppender, ExternallyRolledFileAppender, FileAppender, JDBCAppender, JMSAppender, LF5Appender, NTEventLogAppender, NullAppender, RollingFileAppender, SMTPAppender, SocketAppender, SocketHubAppender, SyslogAppender, TelnetAppender, WriterAppender

Submit " file" to Facebook Submit " file" to Digg Submit " file" to Submit " file" to StumbleUpon Submit " file" to Google

Tags: None Add / Edit Tags
Java SE , XML