Page 1 of 1

log4j configuration

Posted: Wed Apr 16, 2014 6:30 pm
by pmurali26@gmail.com
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!!

Re: log4j configuration

Posted: Thu Apr 17, 2014 12:27 pm
by adrian
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

Re: log4j configuration

Posted: Thu Mar 21, 2019 11:14 pm
by c094728
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?

Re: log4j configuration

Posted: Fri Mar 22, 2019 11:01 am
by Radu
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