Forum Home » Fuse Distributions » Fuse Mediation Router

Thread: Separate Log Files Per Bundle

 

Permlink Replies: 1 - Last Post: Mar 7, 2012 8:18 AM Last Post By: davsclaus Threads: [ Previous | Next ]
eric.bender

Posts: 25
Registered: 12/05/11
Separate Log Files Per Bundle
Posted: Mar 6, 2012 4:36 PM
  Click to reply to this thread Reply
Hello all,

As more developer start working within the servicemix framework, I am trying to setup so that each deployed application bundle writes to it's own log file.

I tried what is listed at http://fusenotes.blogspot.com/2011/02/logging-per-application-in-servicemix-4.html and that seems to make the system write to different log files based on the bundle, but in our routes the use of the log EIP <log message="ABC"/> still writes to the servicemix.log.

What is the best method to have a custom bundle write to it's own log file?

My etc/org.ops4j.pax.logging.cfg looks like this

# Root logger
log4j.rootLogger = INFO, out, sift, osgi:VmLogAppender
log4j.throwableRenderer=org.apache.log4j.OsgiThrowableRenderer
 
log4j.appender.sift.key=app.name
log4j.appender.sift.appender.file=${karaf.data}/log/$\\{app.name\\}.log
 
# CONSOLE appender not used by default
log4j.appender.stdout=org.apache.log4j.ConsoleAppender
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
log4j.appender.stdout.layout.ConversionPattern=%d{ABSOLUTE} | %-5.5p | %-16.16t | %-32.32c{1} | %X{bundle.id} - %X{bundle.name} - %X{bundle.version} | %m%n
 
# File appender
log4j.appender.out=org.apache.log4j.RollingFileAppender
log4j.appender.out.layout=org.apache.log4j.PatternLayout
log4j.appender.out.layout.ConversionPattern=%d{ABSOLUTE} | %-5.5p | %-16.16t | %-32.32c{1} | %X{bundle.id} - %X{bundle.name} - %X{bundle.version} | %m%n
log4j.appender.out.file=${karaf.data}/log/servicemix.log
log4j.appender.out.append=true
log4j.appender.out.maxFileSize=100MB
log4j.appender.out.maxBackupIndex=10
 
# Sift appender
log4j.appender.sift=org.apache.log4j.sift.MDCSiftingAppender
log4j.appender.sift.key=bundle.name
log4j.appender.sift.default=servicemix
log4j.appender.sift.appender=org.apache.log4j.FileAppender
log4j.appender.sift.appender.layout=org.apache.log4j.PatternLayout
log4j.appender.sift.appender.layout.ConversionPattern=%d{ABSOLUTE} | %-5.5p | %-16.16t | %-32.32c{1} | %m%n
log4j.appender.sift.appender.file=${karaf.data}/log/$\\{bundle.name\\}.log
log4j.appender.sift.appender.append=true
log4j.logger.org.apache.camel = INFO


and I am using a simple spring method invoc in my beans.xml

<bean class="org.springframework.beans.factory.config.MethodInvokingFactoryBean">
		<property name="targetClass">
			<value>org.slf4j.MDC</value>
		</property>
		<property name="targetMethod">
			<value>put</value>
		</property>
		<property name="arguments">
			<list>
				<value>app.name</value>
				<value>MDM-RealTime</value>
			</list>
		</property>	
	</bean>
davsclaus

Posts: 1,893
Registered: 10/14/08
Re: Separate Log Files Per Bundle
Posted: Mar 7, 2012 8:18 AM   in response to: eric.bender in response to: eric.bender
  Click to reply to this thread Reply
<log> will by default use the route id as the logger name. So I guess you may have to set a fixed log name on <log> or tweak your log configuration to include the route ids. Or something like that.