Friday, August 1, 2008

Loading multiple property files using Spring

While loading multiple files using spring the following property needs to be added
into bean of the first xml which gets loaded.


< name="ignoreUnresolvablePlaceholders" value="true"/>

Else the subsequent property files will not be loaded.

Some useful unix commands i came across today

vmstat [pamam1] [param2]

shows the server statics along with swap space, cache,io and cpu utilization.

this stats are shown [param2] number of times with [param1] duration in between.

top

this command also shows the server statistics in detail with
contribution from each process.
This also shows the memory used,cpu utilization and command used for each thread.

finger

Shows the user who are currently logged into the node.

Simplest way to Configure Logging using Log4j

Ensure the log4j.jar & log4j.properties are in the classpath

Add the following into the required classes where logging is needed , so that log shows file name for each logger statement .

private static org.apache.log4j.Logger logger = org.apache.log4j.Logger.getLogger([classname].class);

folowed by logger.[info,debug,error,fatal etc]("logger message");

Contents in Log 4j.properties

log4j.rootLogger=ON, ROOT[enabling the root logger]
log4j.appender.ROOT=org.apache.log4j.DailyRollingFileAppender[saving logs on the daily basis with date appended]
log4j.appender.ROOT.File=/a/b/c.log[root log file path]
log4j.appender.ROOT.layout=org.apache.log4j.PatternLayout
log4j.appender.ROOT.layout.ConversionPattern=%d{dd MMM yyyy HH:mm:ss } %-5p [%t] %c{2} - %m%n [pattern for display in each line]

#FILE APPENDER [another logger file ]
log4j.appender.F2=org.apache.log4j.DailyRollingFileAppender
log4j.appender.F2.File=/a/b/d.log
log4j.appender.F2.layout=org.apache.log4j.PatternLayout
log4j.appender.F2.layout.ConversionPattern=%d{dd MMM yyyy HH:mm:ss } %-5p [%t] %c{2} - %m%n


log4j.logger.org.apache=ERROR[apache specific errors to be shown on both logger files]
log4j.logger.com.example=DEBUG,F2[for com.example modules debug status messages to be shown in second logger file]

For Log4j debugging
Append -Dlog4j.debug in JAVA_OPTS in catalina.sh which will enable detailed logs in catalina.out showing the logger configerations.

 
Free Domain Names @ .co.nr!