“optional” dependency with scope “provided” in Maven

Did you check this documentation. It describes your use case very good. Marking dependencies as optional will not resolve them as transitive dependencies in the application which use your library (even if the scope is compile). In difference to <scope>provided</scope> which is used for required dependencies which will be provided by the runtime environment an … Read more

How to set maximum number of rolls and maximum log size for tomcat?

As Tomcat internally uses JUL to log , you can use the system property java.util.logging.config.file to specify the file path of the properties file. For the format of this properties file , you can refer to your JRE_HOME/lib/logging.properties (which is the default configuration file used by JUL) However, JUL does not support the daily rotation … Read more

How to configure log4j 2.x purely programmatically?

package com; import org.apache.logging.log4j.Level; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import org.apache.logging.log4j.core.Appender; import org.apache.logging.log4j.core.LoggerContext; import org.apache.logging.log4j.core.appender.ConsoleAppender; import org.apache.logging.log4j.core.config.AppenderRef; import org.apache.logging.log4j.core.config.Configuration; import org.apache.logging.log4j.core.config.LoggerConfig; import org.apache.logging.log4j.core.layout.PatternLayout; import java.nio.charset.Charset; public class MyLoggerTest { public static void main(String[] args){ LoggerContext context= (LoggerContext) LogManager.getContext(); Configuration config= context.getConfiguration(); PatternLayout layout= PatternLayout.createLayout(“%m%n”, null, null, Charset.defaultCharset(),false,false,null,null); Appender appender=ConsoleAppender.createAppender(layout, null, null, “CONSOLE_APPENDER”, null, null); appender.start(); AppenderRef … Read more

Mixing log4j 1.x and log4j 2

Are you aware that log4j2 includes a bridge for log4j-1.2? You can use it by removing the old log4j-1.2.17.jar, and include these three jars: log4j-api-2.x.jar log4j-core-2.x.jar log4j-1.2-api-2.x.jar This will result in all calls that your application makes to the log4-1.2 API to be routed to the log4j2 implementation. The FAQ has a diagram that may … Read more

Filtering out log4j messages from third-party frameworks?

In my log4j.properties file I set the root logger logging level to ERROR. Then for packages I specifically want to log, like my application code, I set the logging level to INFO or DEBUG. log4j.rootLogger=ERROR, stdout log4j.logger.com.initech.tps=DEBUG log4j.logger.org.hibernate.SQL=INFO I see co-workers who set root logging low and then end up listing everything they don’t want … Read more

Log4j.properties in Spring boot

If you want spring boot to use log4j instead of its own default logging (logback) then you have to exclude default logging and include the log4j dependency for spring boot in your pom.xml: <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter</artifactId> <exclusions> <exclusion> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-logging</artifactId> </exclusion> </exclusions> </dependency> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-log4j</artifactId> </dependency> that way is going to look for your … Read more

Time based triggering policy in log4j2

1 here indicates 1 day and not 1 hour. I have manually tested with below configuration. <RollingFile name=”T” fileName=”/data_test/log/abc.log” filePattern=”/data_test/log/abc-%d{MM-dd-yyyy}-%i.log”> <PatternLayout> <Pattern>%d{ISO8601} %-5p [%t] (%F:%L) – %m%n</Pattern> </PatternLayout> <Policies> <TimeBasedTriggeringPolicy interval=”1″ modulate=”true”/> <SizeBasedTriggeringPolicy size=”100 KB” /> </Policies> </RollingFile> For manual testing, I change the system date and time. First, try with increasing 1 hour. The … Read more

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