2

I am writing a curation task and would like to write to my own log files (like: [dspace]/log/myCurationTask.log) from within the task for this matter, instead of to the dspace.log.

How would I achieve this using as much of the standard DSpace procedures as possible?

MartinW
  • 4,966
  • 2
  • 24
  • 60
  • In case it is helpful to know, it is possible to send output to standard out in a curation task. Unfortunately, this information is not captured if you run the task from the curation task queue. The solution to your question could be useful to other DSpace users running complex curation tasks. – terrywb Oct 11 '16 at 11:00

1 Answers1

2

Here is the log4j.properties file: https://github.com/DSpace/DSpace/blob/dspace-5.6/dspace/config/log4j.properties

You could copy the configuration for A1 (or define your own), name it A4 and let the logs for your specific packages or classes also be sent to the A4 appender like this

log4j.logger.org.dspace.etc.etc = INFO, A4
log4j.additivity.org.dspace.etc.etc = false

The line that specifies the log file in the A1 log file is this one: log4j.appender.A1.File=${log.dir}/dspace.log

In your java class you can then send your text to the log with this

import org.apache.log4j.Logger;

public class SomeClass {

    /**
     * log4j logger
     */
    private static final Logger log = Logger.getLogger(SomeClass.class);

You can then use log.info, log.warn, log.error, log.debug...

Antoine Snyers
  • 682
  • 3
  • 7