jQuery in Action, 2nd edition
The moose likes Java in General and the fly likes Log4J custom appender Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of The Mikado Method this week in the Agile and other Processes forum!
JavaRanch » Java Forums » Java » Java in General
Reply Bookmark "Log4J custom appender" Watch "Log4J custom appender" New topic
Author

Log4J custom appender

Jim Janssens
Ranch Hand

Joined: Sep 24, 2004
Posts: 210
I'm writing a custom JMS appender for log4j that publishes to a queue (I know there is one by default, but that one uses a topic).

Now, in my configuration file I have this:

log4j.appender.jms=JMSQueueAppender
log4j.appender.jms.ProviderURL=iiop://localhost:2809
log4j.appender.jms.QueueFactoryName=jms/LoggingCF
log4j.appender.jms.QueueName=jms/LoggingQueue
log4j.appender.jms.layout=org.apache.log4j.PatternLayout
log4j.appender.jms.layout.ConversionPattern=[%C{1}]%-4r [%t] %-5p %c %x - %m%n
log4j.rootLogger=DEBUG, jms

My appender class extends the Skeleton thing and I have get/setters for the
properties:

ProviderURL
QueueFactoryName
QueueName

but, when I run this, the values appear to be NULL. Do I need to do more then just create get/setters for these properties in my appender class ? ...
[ November 26, 2004: Message edited by: Koen Serneels ]
Jim Janssens
Ranch Hand

Joined: Sep 24, 2004
Posts: 210
Ok I solved this.
I placed my code in the constructor that used some of the options. But its kind of logic that the options cannot be set until an instance of the class is created. :roll:

So I moved it to -> public void activateOptions() (is a method of the OptionHandler interface implemented by Skeleton) which is called after all the options are set. Thats it !
 
I agree. Here's the link: http://zeroturnaround.com/jrebel - it saves me about five hours per week
 
subject: Log4J custom appender
 
Similar Threads
Avoid additional server.log debug lines
remove log4j appender from an API
Problem initializing log4j
JMSAppender and jboss.
getting errors I can't explain...anyone can help out ?