log4j configuration

Having trouble installing <oXygen/>? Got a bug to report? Post it all here.
pmurali26@gmail.com
Posts: 1
Joined: Wed Apr 16, 2014 2:07 am

log4j configuration

Post by pmurali26@gmail.com » Wed Apr 16, 2014 6:30 pm

Hey, Did you get a solution to configure the lo4j. I am usng 14.2 oxygen xml developer and need guidance in setting up the loggers. Any help is highly appreciated!!

adrian
Posts: 2666
Joined: Tue May 17, 2005 4:01 pm

Re: log4j configuration

Post by adrian » Thu Apr 17, 2014 12:27 pm

Hi,

I split the topic. The original poster on the initial topic left the message more than 10 years ago (Sep 19, 2003) and refers to a very old version (Oxygen 2.x) of the Eclipse plugin.

What problems have you encountered in v14.2 that you want to enable logging?
Enabling logging is the last resort and is necessary only when encountering a problem or error that is not correctly handled by the application.

Note that Oxygen runs very slow while logging is enabled, so we only recommend enabling it for debugging purposes (definitely not in production work).
In addition, the generated log is not very user friendly, so it may be difficult to interpret. We recommend discussing the problem with our support team and letting them interpret the logs whenever possible.

Having said that, you can enable logging in Oxygen with a 'log4j.properties' file placed in the Oxygen installation directory (or Oxygen plugin 'lib' folder for the Eclipse plugin).
The 'log4j.properties' file must specify the logger configuration:

Code: Select all

log4j.rootCategory= debug, R2

log4j.appender.R2=org.apache.log4j.RollingFileAppender
log4j.appender.R2.File=${user.home}/Desktop/oxygenLog/oxygen.log
log4j.appender.R2.MaxFileSize=12000KB
log4j.appender.R2.MaxBackupIndex=20
log4j.appender.R2.layout=org.apache.log4j.PatternLayout
log4j.appender.R2.layout.ConversionPattern=%r %p [ %t ] %c - %m%n
This logger configuration places the generated log files (oxygen.log.*), of maximum ~12MB each, in a folder named 'oxygenLog' from your Desktop.

Regards,
Adrian
Adrian Buza
<oXygen/> XML Editor, Schema Editor and XSLT Editor/Debugger
http://www.oxygenxml.com

c094728
Posts: 2
Joined: Wed Sep 12, 2018 1:25 am

Re: log4j configuration

Post by c094728 » Thu Mar 21, 2019 11:14 pm

I want to include logging to a file for errors in my plugin. You said I could include log4j.properties file in my plugin lib directory but that does not seem to work. It only works if I put the log4j.properties file in the oxygen installation folder. How can I make it part of my plugin installation?

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

Re: log4j configuration

Post by Radu » Fri Mar 22, 2019 11:01 am

Hi,

About this remark:
You said I could include log4j.properties file in my plugin lib directory but that does not seem to work.
Oxygen is also available as a plugin for the Eclipse workbench so this particular advice was given in that context and does not have anything to do with your particular request.

Coming back to your problem:
You have an Oxygen plugin which uses Log4j logging. Oxygen also uses Log4j logging and loads its configuration from the "OXYGEN_INSTALL_DIR\log4j.properties" file. This is not configurable, you cannot tell Oxygen to load the logging information from another place.
But maybe what you could do in your plugin's Java code would be to have some static block which adds an appender to the log system and that appender can also be a file appender:

Code: Select all

   /**
* Logger for logging.
*/
private static Logger logger = Logger.getLogger("my.plugin.logger");
{
logger.removeAllAppenders();
logger.addAppender(new FileAppender(...)));
}
Regards,
Radu
Radu Coravu
<oXygen/> XML Editor
http://www.oxygenxml.com

Post Reply