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";
32 private static final String CDM_LOGFILE
= "cdm.logfile";
34 protected void configureLogFile() {
35 PatternLayout layout
= new PatternLayout("%d %p [%c] - %m%n");
36 String logFile
= findProperty(CDM_LOGFILE
, false);
37 if (logFile
== null) {
38 logger
.info("No logfile specified, runing without.");
42 RollingFileAppender appender
= new RollingFileAppender(layout
, logFile
);
43 appender
.setName(ROLLING_FILE_APPENDER
);
44 appender
.setMaxBackupIndex(3);
45 appender
.setMaxFileSize("2MB");
46 Logger
.getRootLogger().addAppender(appender
);
47 logger
.info("logging to :" + logFile
);
48 } catch (IOException e
) {
49 logger
.error("Creating RollingFileAppender failed:", e
);
54 * @see org.springframework.beans.factory.InitializingBean#afterPropertiesSet()
57 public void afterPropertiesSet() throws Exception
{