I'm looking for a way to disable log4j.properties file. I've found out some online solution, but none works:
Disable log4j console logging and enable file logging
Disabling Log4J Output in Java
I've followed this tutorial tutorial SLF4J Tutorial for Beginners , but I didn't find a way to modifiy or to disable logging.
I'm developing OPCUA UA Stack client ,using Unified Architecture Java Stack and Sample Code. org.slf4j, SLF4J logging facade is a dependency mandatory.
In my Maven project, I'm using together to the SLF4J dependency the below dependency:
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-jdk14</artifactId>
<version>1.7.25</version>
<scope>runtime</scope>
</dependency>
log4j.properties is:
# Normal log properties - Logs Warnings, Errors and Severe
log4j.rootLogger=INFO, stdout
# Print info messages
log4j.logger.org.opcfoundation.ua=INFO
# stdout outputs to System.out.
log4j.appender.stdout=org.apache.log4j.ConsoleAppender
# stdout uses PatternLayout.
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
# The conversion pattern uses format specifiers. You might want to
# change the pattern an watch the output format change.
log4j.appender.stdout.layout.ConversionPattern=%-4r %-5p [%t] %37c %3x - %m%n
# stderr outputs to System.err.
log4j.appender.stderr=org.apache.log4j.ConsoleAppender
log4j.appender.stderr.target=System.err
# stdout uses PatternLayout.
log4j.appender.stderr.layout=org.apache.log4j.PatternLayout
# The conversion pattern uses format specifiers. You might want to
# change the pattern an watch the output format change.
log4j.appender.stderr.layout.ConversionPattern=%-4r %-5p [%t] %37c %3x - %m%n
I tested different solution, I've tried to delete files from this path, but it's carrying on to print the same Pattern.
I modify the conversione pattern in the file, but it didn't work
log4j.appender.stdout.layout.ConversionPattern=%-4r %-5p [%t] %37c %3x - %m%n
#log4j.appender.stdout.layout.ConversionPattern=%d{yyyy-MM-dd HH:mm:ss} %-5p %c{1} - %m%n
if I run the application with The second statement, on console I'll always the first ConversionPattern. It seems to take the layout somewhere else.