forked from sakaiproject/sakai
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
SAK-29086 Quartz job to log messages.
The is a simple quartz jobs that allows an administrator to write an arbitrary message into the logs. This can be used for regular timestamping of the log files or for debugging the logging configuration.
- Loading branch information
Showing
3 changed files
with
83 additions
and
1 deletion.
There are no files selected for viewing
34 changes: 34 additions & 0 deletions
34
...ared/src/java/org/sakaiproject/component/app/scheduler/jobs/logmessage/LogMessageJob.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
package org.sakaiproject.component.app.scheduler.jobs.logmessage; | ||
|
||
import org.apache.commons.logging.Log; | ||
import org.apache.commons.logging.LogFactory; | ||
import org.quartz.JobExecutionException; | ||
import org.sakaiproject.component.app.scheduler.jobs.AbstractConfigurableJob; | ||
|
||
/** | ||
* This is a simple Job that allows a message to be logged. | ||
* This is useful for testing and time stamping the log files. | ||
*/ | ||
public class LogMessageJob extends AbstractConfigurableJob { | ||
|
||
@Override | ||
public void runJob() throws JobExecutionException { | ||
String level = getConfiguredProperty("level"); | ||
String message = getConfiguredProperty("message"); | ||
String logger = getConfiguredProperty("logger"); | ||
Log log = LogFactory.getLog(logger); | ||
if ("trace".equalsIgnoreCase(level)) { | ||
log.trace(message); | ||
} else if ("debug".equalsIgnoreCase(level)) { | ||
log.debug(message); | ||
} else if ("info".equalsIgnoreCase(level)) { | ||
log.info(message); | ||
} else if ("warn".equalsIgnoreCase(level)) { | ||
log.warn(message); | ||
} else if ("error".equalsIgnoreCase(level)) { | ||
log.error(message); | ||
} else if ("fatal".equalsIgnoreCase(level)) { | ||
log.fatal(message); | ||
} | ||
} | ||
} |
6 changes: 6 additions & 0 deletions
6
...red/src/java/org/sakaiproject/component/app/scheduler/jobs/logmessage/Messages.properties
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
level=Level | ||
level.description=The level of the logging (eg: trace,debug,info,warn,error,fatal) | ||
message=Message | ||
message.description=The message to be logged. | ||
logger=Logger | ||
logger.description=The logger to use. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters