r113 - in trunk/cantharella.web/src/main: java/nc/ird/cantharella/web/config resources
Author: acheype Date: 2013-02-15 07:40:39 +0100 (Fri, 15 Feb 2013) New Revision: 113 Url: http://forge.codelutin.com/projects/cantharella/repository/revisions/113 Log: add the variable in the cantharella.conf to define the log4j configuration filepath Modified: trunk/cantharella.web/src/main/java/nc/ird/cantharella/web/config/WebContext.java trunk/cantharella.web/src/main/resources/cantharella.conf trunk/cantharella.web/src/main/resources/log4j_prod.xml Modified: trunk/cantharella.web/src/main/java/nc/ird/cantharella/web/config/WebContext.java =================================================================== --- trunk/cantharella.web/src/main/java/nc/ird/cantharella/web/config/WebContext.java 2013-02-15 05:08:09 UTC (rev 112) +++ trunk/cantharella.web/src/main/java/nc/ird/cantharella/web/config/WebContext.java 2013-02-15 06:40:39 UTC (rev 113) @@ -22,6 +22,7 @@ */ package nc.ird.cantharella.web.config; +import java.io.FileNotFoundException; import java.util.ArrayList; import java.util.Collections; import java.util.Comparator; @@ -30,6 +31,7 @@ import java.util.List; import java.util.Locale; import java.util.Map; +import javax.annotation.PostConstruct; import javax.annotation.Resource; import javax.validation.ValidatorFactory; @@ -53,9 +55,11 @@ import org.springframework.context.annotation.ImportResource; import org.springframework.context.support.MessageSourceAccessor; import org.springframework.context.support.ReloadableResourceBundleMessageSource; +import org.springframework.util.Log4jConfigurer; /** * Spring context for the web layer + * * @author Mickael Tricot * @author Adrien Cheype */ @@ -67,66 +71,88 @@ @Configuration public abstract class WebContext { - /** Cookie key for authentification */ + /** + * Cookie key for authentification + */ public static final String AUTH_COOKIE_KEY = "LoggedIn"; - - /** Cookie max age for authentification */ + /** + * Cookie max age for authentification + */ public static final int AUTH_COOKIE_MAX_AGE = (int) Duration.days(1).seconds(); - /** * Countries: Locale -> country code + country name (sorted by country name) */ public static final Map<Locale, Map<String, String>> COUNTRIES; - - /** Country codes: Locale -> country code (sorted by country name) */ + /** + * Country codes: Locale -> country code (sorted by country name) + */ public static final Map<Locale, List<String>> COUNTRY_CODES; - - /** HTTP cache duraction */ + /** + * HTTP cache duraction + */ public static final Duration HTTP_CACHE_DURATION = Duration.days(1); - - /** HTTP maximum upload */ + /** + * HTTP maximum upload + */ public static final Bytes HTTP_MAXIMUM_UPLOAD = Bytes.megabytes(1); - - /** HTTP request logger window size */ + /** + * HTTP request logger window size + */ public static final int HTTP_REQUEST_LOGGER_WINDOW_SIZE = 2000; - - /** HTTP session max page maps */ + /** + * HTTP session max page maps + */ public static final int HTTP_SESSION_MAX_PAGE_MAPS = 5; - - /** HTTP time out */ + /** + * HTTP time out + */ public static final Duration HTTP_TIME_OUT = Duration.seconds(30); - - /** Référentiels codes */ + /** + * Référentiels codes + */ public static final List<Integer> REFERENTIEL_CODES = new ArrayList<Integer>(DataContext.REFERENTIELS.keySet()); - - /** Percent format precision */ + /** + * Percent format precision + */ public static final int PERCENT_PRECISION = 2; - - /** The maximum number of digits allowed in the fraction portion of doubles **/ + /** + * The maximum number of digits allowed in the fraction portion of doubles * + */ public static final int DOUBLE_MAX_FRACTION_DIGIT = 3; - - /** The maximum rows number displayed for a list page */ + /** + * The maximum rows number displayed for a list page + */ public static final int ROWS_PER_PAGE = 20; - - /** Message source for data layer */ + /** + * Message source for data layer + */ @Resource(name = "dataMessageSource") private MessageSourceAccessor dataMessageSource; - - /** Validator factory of the data layer */ + /** + * Validator factory of the data layer + */ @Resource(name = "validatorFactory") private ValidatorFactory validatorFactory; - - /** Debug mode */ + /** + * Debug mode + */ @Value("${app.debug}") protected boolean appDebugProperty; - - /** Optimize mode */ + /** + * Optimize mode + */ @Value("${app.optimize}") protected boolean appOptimizeProperty; - - /** Wicket configuration string ("development" or "deployment") */ + /** + * Wicket configuration string ("development" or "deployment") + */ @Value("${wicket.configuration}") protected String wicketConfiguration; + /** + * Log4j configuration filepath + */ + @Value("${log4j.config}") + protected String log4jConfig; static { Map<Locale, Map<String, String>> countries = new HashMap<Locale, Map<String, String>>( @@ -196,4 +222,14 @@ return new WebApplicationImpl(appDebugProperty, appOptimizeProperty, runtimeWicketConf, new WebMessages( dataMessageSource), new WebMessages(webMessageSource())); } + + /** + * Init the log4j configuration filepath + * + * @throws FileNotFoundException + */ + @PostConstruct + public void initLog4j() throws FileNotFoundException { + Log4jConfigurer.initLogging(log4jConfig); + } } Modified: trunk/cantharella.web/src/main/resources/cantharella.conf =================================================================== --- trunk/cantharella.web/src/main/resources/cantharella.conf 2013-02-15 05:08:09 UTC (rev 112) +++ trunk/cantharella.web/src/main/resources/cantharella.conf 2013-02-15 06:40:39 UTC (rev 113) @@ -32,5 +32,7 @@ wicket.configuration=development # value for production #wicket.configuration=deployment +log4j.config=classpath:log4j.xml +# value for production +#log4j.config=/home/tomcat/.config/log4j_prod.xml - Modified: trunk/cantharella.web/src/main/resources/log4j_prod.xml =================================================================== --- trunk/cantharella.web/src/main/resources/log4j_prod.xml 2013-02-15 05:08:09 UTC (rev 112) +++ trunk/cantharella.web/src/main/resources/log4j_prod.xml 2013-02-15 06:40:39 UTC (rev 113) @@ -27,7 +27,7 @@ <!-- Asynchronous daily rolling file logs --> <appender name="file" class="org.apache.log4j.DailyRollingFileAppender"> - <param name="file" value="${catalina.home}/logs/cantharella.log" /> + <param name="file" value="/opt/tomcat/logs/cantharella.log" /> <param name="threshold" value="info" /> <param name="datePattern" value="'.'yyyy-MM-dd" /> <layout class="org.apache.log4j.PatternLayout">
participants (1)
-
acheype@users.forge.codelutin.com