Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
RE: [corona-dev] List of Logging Tasks

Hi,

            The new appender is implemented and can be found in attachement as patch.

 

·         LevelRollingFileAppender’s configuration

 

New appender extends RollingFileAppender so it can be configured in the same way as normal RollingFileAppender with one exception, value LevelToLog has to be set. The difference in configuration file for this appender looks as follows:

log4j.appender.test.rolling.file4=org.eclipse.corona.logger.log4j.appenders.LevelRollingFileAppender

log4j.appender.test.rolling.file4.File=C:\\Temp\\edka.test4.log

log4j.appender.test.rolling.file4.MaxFileSize=100KB

log4j.appender.test.rolling.file4.MaxBackupIndex=1

log4j.appender.test.rolling.file4.layout=org.apache.log4j.PatternLayout

log4j.appender.test.rolling.file4.layout.ConversionPattern=[%p] %m%n

log4j.appender.test.rolling.file4.LevelToLog=test#org.eclipse.corona.logger.log4j.levels.TestLevel

Bold line, indicates that file C:\\Temp\\edka.test4.log will contain ONLY TestLevel logs.

 

  • LevelRollingFileAppender used with TestLevel:

 

If you want to use LevelRollingFileAppender to log TestLevel value, and you want to use it with other appenders, following changes are required.

 

-          Defining logger itself:

log4j.logger.org.eclipse.corona.project.container.explorer=test#org.eclipse.corona.logger.log4j.levels.TestLevel, test.rolling.file3, eclipse.log, test.rolling.file4

 

-          If you don’t want other appenders to log [TEST] level change, appenders configuration as follows:

log4j.appender.test.rolling.file3=org.apache.log4j.RollingFileAppender

<Some other configuration stuff>

log4j.appender.test.rolling.file3.Threshold=DEBUG

The Threshold value indicates that appender will log all values higher or equal to define Threshold (in this case DEBUG).

 

This is more less all new stuff needed for configuration.

 

Piotr.

 


From: corona-dev-bounces@xxxxxxxxxxx [mailto:corona-dev-bounces@xxxxxxxxxxx] On Behalf Of Jaworowski, Piotr
Sent: Tuesday, September 19, 2006 3:37 PM
To: Corona development
Subject: RE: [corona-dev] List of Logging Tasks

 

Actually, I think that TestLevel should have the lowest level of all possible.

If we set its level to higher than FATAL, than all TestLevel messages will be logged into corona log files, even if we’ll set the rootLogger like

            log4j.rootLogger=FATAL, console

 

To achieve the result wanted by Glenn, we can add new log4j appender (extend DailyRollingFileAppender?) which would filter out all messages with other level than TestLevel.

 

What do you think about this?

 

Piotr.

 


From: corona-dev-bounces@xxxxxxxxxxx [mailto:corona-dev-bounces@xxxxxxxxxxx] On Behalf Of Kalka, Edyta
Sent: Tuesday, September 19, 2006 3:00 PM
To: Corona development
Subject: RE: [corona-dev] List of Logging Tasks

 

Patch commited with one change – TestLevel has not the lowest level but the greatest – higher than FATAL.

If we set TestLevel to TRACE level we would have logs delivered from all levels beginning from the lowest.

 

Configuration inside log4j.properties (as Piotr mentioned):

 

In case of rootLogger:

log4j.rootLogger=test#org.eclipse.corona.logger.log4j.levels.TestLevel, console

 

In case of other loggers:

log4j.logger.org.eclipse.corona.test= test#org.eclipse.corona.logger.log4j.levels.TestLevel, console, test.rolling.file2

 

Log call using CoronaLogService:

Activator.getCoronaLogService().log(CoronaLogService.LOG_TEST, “log service for tests enabled”);

 

Edyta

 


From: Jaworowski, Piotr
Sent: 18 września 2006 17:17
To: Everitt, Glenn; Kalka, Edyta
Cc: O'Flynn, Dennis; Hawkins, Joel; Wright, Jim; Okraszewski, Marcin; Kaczmarek, Pawel
Subject: RE: [corona-dev] List of Logging Tasks

 

Hi,

 

            As an attachment you can find a patch for the org.apache.log4j_1.2.13 plugin. The patch contains an implementation of TestLevel class.

 

Short tutorial, how to use custom test level.

 

1)       log4j.properties file has to be enhanced with new TestLevel like:

log4j.rootLogger=INFO, console ß old line which says that INFO level should be displayed

log4j.rootLogger=test#org.eclipse.corona.logger.log4j.levels.TestLevel, console ß new version of line which says that new test level should be used.

                       

2)       To log something with TestLevel use following line:

logger.log(TestLevel.TEST, "This line will be logged");

 

3)       To test whether TestLevel is enabled, use:

If (logger.isEnabledFor(TestLevel.TEST)) {

            // log test here.

}

 

P.s. Here comes a funny question. The question is what should be the level of test level? Should the TestLevel be equivalent to TRACE or to FATAL? Currently, the TestLevel is the lowest level.

 

Cheers,

Piotr


From: Everitt, Glenn
Sent: Monday, September 18, 2006 2:29 PM
To: Kalka, Edyta
Cc: O'Flynn, Dennis; Hawkins, Joel; Wright, Jim; Jaworowski, Piotr; Okraszewski, Marcin; Kaczmarek, Pawel
Subject: RE: [corona-dev] List of Logging Tasks

 

See my comments on your comments on my comments below.

 


From: Kalka, Edyta
Sent: Monday, September 18, 2006 4:16 AM
To: Everitt, Glenn
Cc: O'Flynn, Dennis; Hawkins, Joel; Wright, Jim; Jaworowski, Piotr; Okraszewski, Marcin; Kaczmarek, Pawel
Subject: RE: [corona-dev] List of Logging Tasks

 

 

 


From: Everitt, Glenn
Sent: 15 września 2006 20:31
To: Kalka, Edyta
Cc: O'Flynn, Dennis; Hawkins, Joel; Wright, Jim; Jaworowski, Piotr; Okraszewski, Marcin; Kaczmarek, Pawel
Subject: RE: [corona-dev] List of Logging Tasks

 

Edyta:

Could we have Piotr determine how to have EcorePlugin logging output put into the same log files used by the CoronaLogService?

 

Yes. I suppose adding new ILogListener could be a solution here.

 

Good, does it make sense for Piotr to work on this?

 

Could we also have Piotr determine how to have output from Corona test classes written to a log specifically for test output?

 

Adding new appender and ‘org.eclipse.corona.test‘ logger wouldn’t be enough?

 

What I wanted was a way to put only output specific to test results to log file.  It seems like we need another log level like TEST to the existing Levels of ERROR, WARNING, INFO, DEBUG.  How hard would that be?

 

Edyta

 

 

 

I know you did a great deal of work on the logging but, we need a task for Piotr that can be easily written as a patch.  It seems that the fewer files involved in a patch the better.

 

You, Dennis and I will continue will the adding logging statements.  After the first pass at logging statements then you and I will do the package renaming.  Next everyone will do more javadoc.

 

 

 


From: Kalka, Edyta
Sent: Friday, September 15, 2006 7:24 AM
To: Everitt, Glenn
Cc: O'Flynn, Dennis; Hawkins, Joel; Wright, Jim; Jaworowski, Piotr; Okraszewski, Marcin; Kaczmarek, Pawel
Subject: RE: [corona-dev] List of Logging Tasks

 

Glenn,

 

I have questions concerning adding headers, cleaning logging etc.

How are we going to split work here?

Should I start from the beginning of list and add: missing headers (event if I’m not the author of the class), log service initialization to activators not using it etc.?

 

Edyta


From: corona-dev-bounces@xxxxxxxxxxx [mailto:corona-dev-bounces@xxxxxxxxxxx] On Behalf Of Kalka, Edyta
Sent: 15 września 2006 12:07
To: Corona development
Subject: RE: [corona-dev] List of Logging Tasks

 

In case of EMF/SDO generated code such sample log call can be found: EcorePlugin.INSTANCE.log(exception) – which wraps log call on org.eclipse.core.runtime.ILog.

 

Edyta

 


From: corona-dev-bounces@xxxxxxxxxxx [mailto:corona-dev-bounces@xxxxxxxxxxx] On Behalf Of Everitt, Glenn
Sent: 14 września 2006 20:59
To: Corona development
Subject: [corona-dev] List of Logging Tasks

 

I went through all of the plugins that I believe are used and looked to see if the CoronaLogService was being used by looking in the plugin’s Activator.  If I found the CoronaLogService being instantiated I checked to see if it was consistently used.  I don’t know how to use the CoronaLogService in plugins without Activators.  We have some plugins that are used as libraries, but I think they still have behavior that needs logged.  We need to figure this part out.  I think we may want to use a different Logging Service for our test plugins.  Currently none of the test plugins are doing any logging just System.out…

 

The conclusion is we have some work to do.  What I found is below we should clean logging up before we change any more package names because I don’t  want to grind through all of the plugins and create this list again

 

 

org.eclipse.corona – CoronaLogService found but needs work

org.eclipse.corona.client.collaboration.event – missing

org.eclipse.corona.client.collaboration.ui – missing

org.eclipse.corona.client.ecf – CoronaLogService found

org.eclipse.corona.client.project.builder – found

org.eclipse.corona.client.project.event – missing

org.eclipse.corona.client.project.ui – missing

org.eclipse.corona.common.collaboration – CoronaLogService found

org.eclipse.corona.common.ecf – no Activator – how do we access the Logger service

org.eclipse.corona.common.project – CoronaLogService found but not used

org.eclipse.corona.container.manager – CoronaLogService found but needs more work

org.eclipse.corona.model.container – missing but generated code, find out if EMF/SDO has another log / debug approach, no Activator

org.eclipse.corona.model.container.edit - missing but generated code, find out if EMF/SDO has another log / debug approach, no Activator

org.eclipse.corona.model.container.editor - missing but generated code, find out if EMF/SDO has another log / debug approach, no Activator

org.eclipse.corona.model.container.project - missing but generated code, find out if EMF/SDO has another log / debug approach, no Activator

org.eclipse.corona.container.project.edit - missing but generated code, find out if EMF/SDO has another log / debug approach, no Activator

org.eclipse.corona.container.project.editor - missing but generated code, find out if EMF/SDO has another log / debug approach, no Activator

org.eclipse.corona.project.container.explorer – found but not used in package org.eclipse.corona.project.container.explorer.actions or views

org.eclipse.corona.project.container.view – CoronaLogService found but needs some work

org.eclipse.corona.repository – CoronaLogService found not bad

org.eclipse.corona.repository.adapter.team – no Activator – how do we access the Logger service

org.eclipse.corona.repository.adapter.wp – CoronaLogService found but not used

org.eclipse.corona.repository.dbms.team – CoronaLogService found but not used

org.eclipse.corona.server.derby – CoronaLogService found

org.eclipse.corona.server.ecf – CoronaLogService found

org.eclipse.corona.server.repository.team – CoronaLogService found

org.eclipse.corona.server.test.container.project – not found, this is a test class does it make sense to log to CoronaLogService or a TestLogService?

org.eclipse.corona.test – not found, this is a test class does it make sense to log to CoronaLogService or a TestLogService?

org.eclipse.corona.test.server.ecf – not found, this is a test class does it make sense to log to CoronaLogService or a TestLogService?  

org.eclipse.corona.ui.tools – missing

test.eclipse.corona – not found, this is a test class does it make sense to log to CoronaLogService or a TestLogService?

test.eclipse.corona.common.project – not found, this is a test class does it make sense to log to CoronaLogService or a TestLogService?

test.eclipse.corona.repository – not found, this is a test class does it make sense to log to CoronaLogService or a TestLogService?

 

 

 

The contents of this e-mail are intended for the named addressee only. It contains information that may be confidential. Unless you are the named addressee or an authorized designee, you may not copy or use it, or disclose it to anyone else. If you received it in error please notify us immediately and then destroy it.

The contents of this e-mail are intended for the named addressee only. It contains information that may be confidential. Unless you are the named addressee or an authorized designee, you may not copy or use it, or disclose it to anyone else. If you received it in error please notify us immediately and then destroy it.

The contents of this e-mail are intended for the named addressee only. It contains information that may be confidential. Unless you are the named addressee or an authorized designee, you may not copy or use it, or disclose it to anyone else. If you received it in error please notify us immediately and then destroy it.

The contents of this e-mail are intended for the named addressee only. It contains information that may be confidential. Unless you are the named addressee or an authorized designee, you may not copy or use it, or disclose it to anyone else. If you received it in error please notify us immediately and then destroy it.

The contents of this e-mail are intended for the named addressee only. It contains information that may be confidential. Unless you are the named addressee or an authorized designee, you may not copy or use it, or disclose it to anyone else. If you received it in error please notify us immediately and then destroy it.
### Eclipse Workspace Patch 1.0
#P org.apache.log4j_1.2.13
Index: src/org/eclipse/corona/logger/log4j/levels/TestLevel.java
===================================================================
RCS file: /usr/local/CVS_REPOSITORY/CoronaIncubator/plugins/org.apache.log4j_1.2.13/src/org/eclipse/corona/logger/log4j/levels/TestLevel.java,v
retrieving revision 1.1
diff -u -r1.1 TestLevel.java
--- src/org/eclipse/corona/logger/log4j/levels/TestLevel.java	19 Sep 2006 11:36:56 -0000	1.1
+++ src/org/eclipse/corona/logger/log4j/levels/TestLevel.java	20 Sep 2006 09:34:43 -0000
@@ -23,21 +23,26 @@
 
 /**
  * Defines the custom level recognized by the corona plugin. Used in test
- * plugins for storing special test information in separate files.
+ * plugins for storing special test information in separate files.<br><br>
+ * This level fits into standard levels as follows.<br>
+ * <code><b>
+ * TestLevel < TRACE < DEBUG < INFO < WARN < ERROR < FATAL.
+ * </b></code><br><br>
  * 
  * @author <a href="mailto:piotr.jaworowski@xxxxxxxxxxxxx";>Piotr Jaworowski</a>
+ * @see ThresholdRollingFileAppender
  */
 public class TestLevel extends Level {
 
 	/**
 	 * TestLevel level value.
 	 */
-	public static final int TEST_INT = Level.FATAL_INT + 2;
+	public static final int TEST_INT = Level.TRACE_INT - 1;
 
 	/**
 	 * We assimilate TEST to DEBUG on Syslog.
 	 */
-	private static final int SYSLOG_TEST_INT = 0;
+	private static final int SYSLOG_TEST_INT = 7;
 
 	/** Test level instance */
 	public static final TestLevel TEST = new TestLevel(TEST_INT, "TEST",
Index: .classpath
===================================================================
RCS file: /usr/local/CVS_REPOSITORY/CoronaIncubator/plugins/org.apache.log4j_1.2.13/.classpath,v
retrieving revision 1.2
diff -u -r1.2 .classpath
--- .classpath	16 Aug 2006 09:31:31 -0000	1.2
+++ .classpath	20 Sep 2006 09:34:43 -0000
@@ -1,7 +1,7 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <classpath>
 	<classpathentry kind="src" path="src"/>
-	<classpathentry exported="true" kind="lib" path="log4j-1.2.13.jar"/>
+	<classpathentry exported="true" sourcepath="D:/Projects/Corona/logging-log4j-1.2.13/src" kind="lib" path="log4j-1.2.13.jar"/>
 	<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
 	<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
 	<classpathentry kind="output" path="bin"/>
Index: src/org/eclipse/corona/logger/log4j/appenders/LevelRollingFileAppender.java
===================================================================
RCS file: src/org/eclipse/corona/logger/log4j/appenders/LevelRollingFileAppender.java
diff -N src/org/eclipse/corona/logger/log4j/appenders/LevelRollingFileAppender.java
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ src/org/eclipse/corona/logger/log4j/appenders/LevelRollingFileAppender.java	1 Jan 1970 00:00:00 -0000
@@ -0,0 +1,93 @@
+/*
+ * Copyright (c) 2005-2006 Compuware Corporation and others.
+ * All rights reserved. This program and the accompanying 
+ * materials are made available under the terms of the 
+ * Eclipse Public License v1.0 which accompanies this 
+ * distribution, and is available at:
+ * http://www.eclipse.org/legal/epl-v10.html 
+ * 
+ * Contributors:
+ *     Compuware Corporation - initial API and implementation
+ *
+ * CVS Attributes:
+ * $Author:  $
+ * $Date:  $
+ * $Id:  $
+ * $Revision:  $
+ */
+
+package org.eclipse.corona.logger.log4j.appenders;
+
+import org.apache.log4j.Level;
+import org.apache.log4j.RollingFileAppender;
+import org.apache.log4j.helpers.LogLog;
+import org.apache.log4j.spi.LoggingEvent;
+
+/**
+ * LevelRollingFileAppender loggs events of level equal to one defined by 'LevelToLog' parameter.
+ * Appende of this type has to have 'LevelToLog' value defined in configuration file.
+ * <br><br> 
+ * Configuration example:
+ * <code>
+ * log4j.appender.test.rolling.file4=org.eclipse.corona.logger.log4j.appenders.ThresholdRollingFileAppender
+ * log4j.appender.test.rolling.file4.File=C:\\Temp\\edka.test4.log
+ * log4j.appender.test.rolling.file4.MaxFileSize=100KB
+ * log4j.appender.test.rolling.file4.MaxBackupIndex=1
+ * log4j.appender.test.rolling.file4.layout=org.apache.log4j.PatternLayout
+ * log4j.appender.test.rolling.file4.layout.ConversionPattern=[%p] %m%n
+ * <b>log4j.appender.test.rolling.file4.LevelToLog=test#org.eclipse.corona.logger.log4j.levels.TestLevel</b>
+ * </code><br><br>
+ * With above example, file 'edka.test4.log' will contain only TestLevel logs. 
+ * 
+ * @author <a href="mailto:piotr.jaworowski@xxxxxxxxxxxxx";>Piotr Jaworowski</a>
+ */
+public class LevelRollingFileAppender extends RollingFileAppender {
+	/** 
+	 * Only events with this level will be logged in the log file. 
+	 */
+	private Level levelToLog = null;
+	
+	//TODO what about a DailyRollingFileAppender?
+	/**
+	 * {@inheritDoc}
+	 */
+	public void activateOptions() {
+		super.activateOptions();
+		if ( levelToLog == null) {
+			LogLog
+					.error("Failed to initialize appender.\nAppender "
+							+ this.getName()
+							+ " has to have 'LevelToLog' defined in configuration properties file.\nAppenders of type "
+							+ this.getClass().getName()
+							+ " are ONLY logging events with 'LevelToLog' level.");
+		}
+	}
+
+	/**
+	 * {@inheritDoc}
+	 */
+	public void append(LoggingEvent event) {
+		if (event.getLevel().equals(getLevelToLog())) {
+			super.append(event);
+		}
+	}
+
+	/**
+	 * Getter method for levelToLog. 
+	 * @return the levelToLog.
+	 */
+	public Level getLevelToLog() {
+		return levelToLog;
+	}
+
+	/**
+	 * Setter method for levelToLog.
+	 * @param levelToLog the levelToLog to set.
+	 */
+	public void setLevelToLog(Level levelToLog) {
+		this.levelToLog = levelToLog;
+	}
+
+	
+}
+

Back to the top