How to enable logging for plugins

Having trouble installing <oXygen/>? Got a bug to report? Post it all here.
mandar.j
Posts: 3
Joined: Fri Jul 27, 2012 11:16 am

How to enable logging for plugins

Post by mandar.j » Fri Jul 27, 2012 11:25 am

Hi,

I am trying to create a plugin and somehow I am not able to enable logging for the debugging. I have included logger of log4j in my class but it seems it doesn't show my debugg messages in logging.log.

Any help with a guide to setup logging for plugins or an example would be appreciated.

Thanks,
Mandar

Radu
Posts: 6579
Joined: Fri Jul 09, 2004 5:18 pm

Re: How to enable logging for plugins

Post by Radu » Fri Jul 27, 2012 11:37 am

Hi Mandar,

Oxygen also uses Apache Log4j internally for debug purposes.

What we do when we want to show more logging (or logging for a certain package) is to configure a log4j.properties file in the OXYGEN_INSTALL_DIR.

Our default log4j.properties (which is not present in an installation kit) has the content:

Code: Select all

log4j.rootCategory= info, R

log4j.category.ro.sync.find=info
log4j.category.ro.sync.ecss.images=info
log4j.category.ro.sync.contentcompletion=info
log4j.category.ro.sync.exml.options=info
log4j.category.ro.sync.syntaxhighlight=info
log4j.category.ro.sync.exml.editor.ValidationAssistant=info
log4j.category.ro.sync.exml.editor.xmleditor.XMLErrorScanner=info
log4j.category.ro.sync.exml.project=info
log4j.category.ro.sync.options=info
log4j.category.ro.sync.outline=info
log4j.category.org.apache.commons.httpclient=error
#log4j.category.httpclient.wire=debug

#log4j.logger.ro.sync.svn=DEBUG, Chainsaw
#log4j.logger.CustomSVNKitLogger=DEBUG, R3

# R is the standard output
log4j.appender.R=org.apache.log4j.ConsoleAppender
log4j.appender.R.layout=org.apache.log4j.PatternLayout
log4j.appender.R.layout.ConversionPattern=%r %p [ %t ] %c - %m%n

# R2 will write log to file
log4j.appender.R2=org.apache.log4j.RollingFileAppender
log4j.appender.R2.File=oxygen.log
log4j.appender.R2.MaxFileSize=12000KB
log4j.appender.R2.MaxBackupIndex=4
log4j.appender.R2.layout=org.apache.log4j.PatternLayout
log4j.appender.R2.layout.ConversionPattern=%d %r %p [ %t ] %c - %m%n

# appender for Chainsaw
# Chainsaw v2 is a companion application to Log4j written by members of the Log4j
# http://logging.apache.org/chainsaw/index.html
log4j.appender.Chainsaw=org.apache.log4j.net.SocketAppender
log4j.appender.Chainsaw.remoteHost=localhost
log4j.appender.Chainsaw.port=4445
log4j.appender.Chainsaw.locationInfo=true

# xml log appender output can be opened with Chainsaw
log4j.appender.Xml=org.apache.log4j.RollingFileAppender
log4j.appender.Xml.file=oxygen-log.xml
log4j.appender.Xml.MaxFileSize=12000KB
log4j.appender.Xml.MaxBackupIndex=5
log4j.appender.Xml.layout=org.apache.log4j.xml.XMLLayout
log4j.appender.Xml.append=false

# R3 will write log to file that will be rewritten at start
log4j.appender.R3=org.apache.log4j.FileAppender
log4j.appender.R3.File=oxygen.log
log4j.appender.R3.layout=org.apache.log4j.PatternLayout
log4j.appender.R3.append=false
log4j.appender.R3.layout.ConversionPattern=%d %r %p [ %t ] %c - %m%n
Such a file could also be used to log debug information for your specific packages.

Did you also include the log4j.jar in your plugin's classpath?
If so, you can remove it, the library is also present in our libraries list.

Did you try to add an appender to the logger from the code?
How exactly does the code look like?

Regards,
Radu
Radu Coravu
<oXygen/> XML Editor
http://www.oxygenxml.com

mandar.j
Posts: 3
Joined: Fri Jul 27, 2012 11:16 am

Re: How to enable logging for plugins

Post by mandar.j » Fri Jul 27, 2012 1:38 pm

It worked!! I can see the debug logging. Thanks Radu!

Regards,
Mandar

sebastienlavandier
Posts: 124
Joined: Tue May 29, 2012 5:42 pm

How to customized Oxygen log file

Post by sebastienlavandier » Tue Dec 01, 2015 11:43 am

Hello,

I developed an Oxygen plugin, and now, I want to add my own logs to the oxygen log file (OXYGEN_DIR/output.log).
I added a log4j.properties file in my plugin project with a specific log4j.category to log my own plugin project logs.
Great ! My plugin logs are added to the Oxygen log file.

I prefer that my plugin logs are written to the same oxygen log file, but I want to generate one log file by day, and generated customized log rows, with formated time stamp, and specific log informtion.

Is it possible to do that in Oxygen log file or if I must to implement my own plugin logger ?
What is the best way ?

Thanks in advance for your help.
Sébastien .L

Radu
Posts: 6579
Joined: Fri Jul 09, 2004 5:18 pm

Re: How to enable logging for plugins

Post by Radu » Tue Dec 01, 2015 12:03 pm

Hi Sébastien,

I'm not sure I understand. There is no special "Oxygen log file". Oxygen uses the Apache Log4j libraries to log internal debug messages. And the libraries will output this debug information in the places specified by the "log4j.properties" file which can be placed in the Oxygen installation folder.
So Oxygen logs in your case to the output.log because that's where you configured it to log.
You are also using the Apache Log4j library to log various debug messages, right?
Then it depends on what that particular library has to offer with regard to various message patterns:

http://logging.apache.org/log4j/2.x/man ... ation.html

Regards,
Radu
Radu Coravu
<oXygen/> XML Editor
http://www.oxygenxml.com

Post Reply