java - How to set Spring log4j property file path programmatically -


i using spring-boot way;

public static void main(string[] args) throws exception {          applicationcontext context = new annotationconfigapplicationcontext(springconfiguration.class); 

////

@configuration @componentscan("com.mycompnay") @propertysources({         @propertysource("classpath:application.properties")})  public class springconfiguration {       @bean     public static propertysourcesplaceholderconfigurer propertyplaceholderconfigurer() {         return new propertysourcesplaceholderconfigurer();     } 

i trying understand how can set log4j.properties file way? found way application.properties. how set programatically log4j.properties ?

log4j.properties

log4j.rootlogger=info, console  log4j.appender.console=org.apache.log4j.consoleappender log4j.appender.console.layout=org.apache.log4j.patternlayout log4j.appender.console.layout.conversionpattern=%d %p [%c] - <%m>%n  #debug logging log4j.appender.debugappender=org.apache.log4j.rollingfileappender log4j.appender.debugappender.threshold=debug log4j.appender.debugappender.file=vertx.log log4j.appender.debugappender.maxfilesize=200kb log4j.appender.debugappender.maxbackupindex=5 log4j.appender.debugappender.layout=org.apache.log4j.patternlayout log4j.appender.debugappender.layout.conversionpattern=%d %p [%c] - <%m>%n  log4j.logger.org.springframework=error,console log4j.logger.org.apache=error,console 

however on console still see such loggings:

13:41:59.525 [main] debug o.s.core.env.standardenvironment - adding [systemproperties] propertysource lowest search precedence 

added log4j debug. console output:

log4j: reading configuration url file:/users/idan/ideaprojects/myservice-service/web/build/resources/main/log4j.properties log4j: parsing [root] value=[info, console]. log4j: level token [info]. log4j: category root set info log4j: parsing appender named "console". log4j: parsing layout options "console". log4j: setting property [conversionpattern] [%d %p [%c] - <%m>%n]. log4j: end of parsing "console". log4j: parsed "console" options. log4j: parsing [org.apache] value=[error, console]. log4j: level token [error]. log4j: category org.apache set error log4j: parsing appender named "console". log4j: appender "console" parsed. log4j: handling log4j.additivity.org.apache=[null] log4j: parsing [org.springframework] value=[error, console]. log4j: level token [error]. log4j: category org.springframework set error log4j: parsing appender named "console". log4j: appender "console" parsed. log4j: handling log4j.additivity.org.springframework=[null] log4j: parsing [io.netty] value=[info, console]. log4j: level token [info]. log4j: category io.netty set info log4j: parsing appender named "console". log4j: appender "console" parsed. log4j: handling log4j.additivity.io.netty=[null] log4j: parsing [com.mycompany] value=[debug, console]. log4j: level token [debug]. log4j: category com.mycompany set debug log4j: parsing appender named "console". log4j: appender "console" parsed. log4j: handling log4j.additivity.com.mycompany=[false] log4j: setting additivity "com.mycompany" false log4j: parsing [org.neo4j.jdbc.level] value=[debug, console]. log4j: level token [debug]. log4j: category org.neo4j.jdbc.level set debug log4j: parsing appender named "console". log4j: appender "console" parsed. log4j: handling log4j.additivity.org.neo4j.jdbc.level=[null] log4j: finished configuring. 

thank, ray.

i fixed adding param executable jar:

-dlog4j.configurationfile=file:/path.to/log4j.properties 

Comments

Popular posts from this blog

html - Outlook 2010 Anchor (url/address/link) -

javascript - Why does running this loop 9 times take 100x longer than running it 8 times? -

Getting gateway time-out Rails app with Nginx + Puma running on Digital Ocean -