3 * Copyright (C) 2009 EDIT
4 * European Distributed Institute of Taxonomy
5 * http://www.e-taxonomy.eu
7 * The contents of this file are subject to the Mozilla Public License Version 1.1
8 * See LICENSE.TXT at the top of this package for the full license terms.
10 package eu
.etaxonomy
.cdm
.remote
.config
;
12 import java
.io
.IOException
;
14 import org
.apache
.log4j
.Logger
;
15 import org
.apache
.log4j
.PatternLayout
;
16 import org
.apache
.log4j
.RollingFileAppender
;
17 import org
.springframework
.beans
.factory
.InitializingBean
;
18 import org
.springframework
.context
.annotation
.Configuration
;
21 * @author a.kohlbecker
26 public class LoggingConfigurer
extends AbstractWebApplicationConfigurer
implements InitializingBean
{
31 private static final String ROLLING_FILE_APPENDER
= "rollingFileAppender";
34 * see also <code>eu.etaxonomy.cdm.server.instance.SharedAttributes</code>
36 private static final String CDM_LOGFILE
= "cdm.logfile";
38 protected void configureLogFile() {
39 PatternLayout layout
= new PatternLayout("%d %p [%c] - %m%n");
40 String logFile
= findProperty(CDM_LOGFILE
, false);
41 if (logFile
== null) {
42 logger
.info("No logfile specified, runing without.");
46 RollingFileAppender appender
= new RollingFileAppender(layout
, logFile
);
47 appender
.setName(ROLLING_FILE_APPENDER
);
48 appender
.setMaxBackupIndex(3);
49 appender
.setMaxFileSize("2MB");
50 Logger
.getRootLogger().addAppender(appender
);
51 logger
.info("logging to :" + logFile
);
52 } catch (IOException e
) {
53 logger
.error("Creating RollingFileAppender failed:", e
);
58 * @see org.springframework.beans.factory.InitializingBean#afterPropertiesSet()
61 public void afterPropertiesSet() throws Exception
{