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?
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
...