Logback and Jboss 7 – don’t work together?

You need to exclude the servers version of slf4j from your deployment. Create a jboss-deployment-structure.xml file and place it in either your WARS META-INF or WEB-INF directory. The contents of the file should look like this: <jboss-deployment-structure> <deployment> <!– Exclusions allow you to prevent the server from automatically adding some dependencies –> <exclusions> <module name=”org.slf4j” … Read more

Is it possible to configure logback logger levels on the command line?

Yes, seems there is no such feature. As I understand, it is partly because that logback configuration is more complex so quite difficult to achieve reasonable configuration flexibility by flat string properties. Partly because, imho, it encourages bad practice – placing too many system properties – leads to bloated run-scripts or command lines, more difficult … Read more

Unable to use Spring Property Placeholders in logback.xml

Since Spring Boot 1.3 you have a better way of getting spring properties into your logback-spring.xml configuration: Now you can just add a “springProperty” element. The attribute name refers to the logback property and the attribute source refers to the spring property <springProperty name=”destination” source=”my.loggger.extradest”/> <appender name=”FILE” class=”ch.qos.logback.core.FileAppender”> <file>${destination}</file> … </file> </appender> https://github.com/spring-projects/spring-boot/commit/055ace37f006120b0006956b03c7f358d5f3729f edit: thanks … Read more

Why calling LoggerFactory.getLogger(…) every time is not recommended?

Here is one obvious problem with this approach: the String messages will be constructed on each call to debug(), there is no obvious way to use a guard clause with your wrapper. The standard idiom with log4j/commons-logging/slf4j is to use a guard clause such as: if (log.isDebugEnabled()) log.debug(“blah blah blah”); With the purpose being that … Read more

Setting logback.xml path programmatically

LoggerContext loggerContext = (LoggerContext) LoggerFactory.getILoggerFactory(); loggerContext.reset(); JoranConfigurator configurator = new JoranConfigurator(); InputStream configStream = FileUtils.openInputStream(logbackPropertiesUserFile); configurator.setContext(loggerContext); configurator.doConfigure(configStream); // loads logback file configStream.close();

How to roll the log file on startup in logback

None of the other suggestions was appropriate for my situation. I didn’t want to use a size-and-time-based solution, because it requires configuring a MaxFileSize, and we are using a strictly time-based policy. Here is how I accomplished rolling the file on startup with a TimeBasedRollingPolicy: @NoAutoStart public class StartupTimeBasedTriggeringPolicy<E> extends DefaultTimeBasedFileNamingAndTriggeringPolicy<E> { @Override public void … Read more

How to use multiple configurations with logback in a single project?

OPTION 1: specify the location of the logback configuration file with the logback.configurationFile system property. This does in fact allow you to have multiple configuration files per project. As per the logback documentation, the value of the this property can be a URL, a resource on the class path or a path to a file … Read more

How to create 2 different ROOT loggers with logback?

You will not ever have more than one root-logger, so your question is a bit misleading. What you are looking for is how to fine-tune which events each of the appenders does log. And for that, you add a ThresholdFilter to each of the appenders: http://logback.qos.ch/manual/filters.html#thresholdFilter <filter class=”ch.qos.logback.classic.filter.ThresholdFilter”> <level>INFO</level> </filter> Configure level INFO for the … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)