Missing newline character in rawlogs using log4j and slf4j - maven

I am working on a bug using log4j2 and slf4j. I have been reviewing the commit history in Github, but cannot find where the bug was introduced. In the log file rawlogs.log the newline character %n has been replaced by %replace%n. Please see the example below:
applog.line=16,applog.msg=ConfigChangeListener Initilized!%replace%nXXXXXXXX03172 123456789 2019-06-11 15:06:35.080 devHostname
I am using the following dependencies:
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-api</artifactId>
<version>2.10.0</version>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-core</artifactId>
<version>2.10.0</version>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-to-slf4j</artifactId>
<version>2.10.0</version>
</dependency>
In the files with logs the LoggerFactory is created with the example below:
private static final Logger LOGGER = LoggerFactory.getLogger(ClassName.class);
I have tried using both a log4j2.properties, and log4j2.xml files from log4j2 examples, but always get this error on startup:
2019-06-11 15:19:16,063 warmup - 7 ERROR No log4j2 configuration file found. Using default configuration: logging only errors to the console.
The rawlogs.log file is created and populated on startup.
Has anyone experienced this before? Any insight is appreciated.
EDIT: To clarify, project did not use a .xml or .properties file for configurations. I introduced them in an attempt to expose the root cause of the bug, but have not had success.

Related

Issue with io.github.resilience4j version 1.7.2 (SpelResolverConfigurationOnMissingBean.spelResolver() method that does not exist)

I'm using io.github.resilience4j. Everything is working fine with 1.6.1 version but when upgraded to 1.7.1 version my application is not running. Please find my code changes below.
My pom.xml dependencies
<dependency>
<groupId>io.github.resilience4j</groupId>
<artifactId>resilience4j-core</artifactId>
<version>1.7.1</version>
</dependency>
<dependency>
<groupId>io.github.resilience4j</groupId>
<artifactId>resilience4j-spring-boot2</artifactId>
<version>1.7.1</version>
</dependency>
Here is application.propertes changes
resilience4j.circuitbreaker.configs.default.registerHealthIndicator=true
resilience4j.circuitbreaker.configs.default.slidingWindowSize= 10
resilience4j.circuitbreaker.configs.default.minimumNumberOfCalls=5
resilience4j.circuitbreaker.configs.default.permittedNumberOfCallsInHalfOpenState= 3
resilience4j.circuitbreaker.configs.default.automaticTransitionFromOpenToHalfOpenEnabled=true
resilience4j.circuitbreaker.configs.default.waitDurationInOpenState=5s
resilience4j.circuitbreaker.configs.default.failureRateThreshold=50
resilience4j.circuitbreaker.configs.default.eventConsumerBufferSize=10
resilience4j.circuitbreaker.configs.shared.slidingWindowSize=100
resilience4j.circuitbreaker.configs.shared.permittedNumberOfCallsInHalfOpenState=30
resilience4j.circuitbreaker.configs.shared.waitDurationInOpenState=1s
resilience4j.circuitbreaker.configs.shared.failureRateThreshold=50
resilience4j.circuitbreaker.configs.shared.eventConsumerBufferSize=10
resilience4j.circuitbreaker.instances.profile.registerHealthIndicator=true
resilience4j.circuitbreaker.instances.profile.slidingWindowSize=10
resilience4j.circuitbreaker.instances.profile.minimumNumberOfCalls=10
resilience4j.circuitbreaker.instances.profile.permittedNumberOfCallsInHalfOpenState=3
resilience4j.circuitbreaker.instances.profile.waitDurationInOpenState=5s
resilience4j.circuitbreaker.instances.profile.failureRateThreshold=50
resilience4j.circuitbreaker.instances.profile.eventConsumerBufferSize=10
resilience4j.retry.configs.default.maxAttempts=3
resilience4j.retry.configs.default.waitDuration=100
resilience4j.retry.instances.profile.baseConfig=default
resilience4j.bulkhead.configs.default.maxConcurrentCalls=30
resilience4j.bulkhead.configs.instances.profile.maxWaitDuration=10ms
resilience4j.bulkhead.configs.instances.profile.maxConcurrentCalls=20
resilience4j.thread-pool-bulkhead.configs.default.maxThreadPoolSize=4
resilience4j.thread-pool-bulkhead.configs.default.coreThreadPoolSize=2
resilience4j.thread-pool-bulkhead.configs.default.queueCapacity=2
resilience4j.thread-pool-bulkhead.instances.profile.maxThreadPoolSize=1
resilience4j.thread-pool-bulkhead.instances.profile.coreThreadPoolSize=1
resilience4j.thread-pool-bulkhead.instances.profile.queueCapacity=1
resilience4j.ratelimiter.configs.default.registerHealthIndicator=false
resilience4j.ratelimiter.configs.default.limitForPeriod=10
resilience4j.ratelimiter.configs.default.limitRefreshPeriod=1s
resilience4j.ratelimiter.configs.default.timeoutDuration=0
resilience4j.ratelimiter.configs.default.eventConsumerBufferSize=100
resilience4j.timelimiter.configs.default.cancelRunningFuture=false
resilience4j.timelimiter.configs.default.timeoutDuration=2s
resilience4j.timelimiter.instances.profile.baseConfig=default
Here is controller API changes
private static final String PROFILE="profile";
#GetMapping("/{programType}/profile")
#AdobeIOAuthentication
#RateLimiter(name = PROFILE)
#TimeLimiter(name = PROFILE)
#CircuitBreaker(name = PROFILE)
#Bulkhead(name = PROFILE)
Error I'm getting while getting building
Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled.
2021-08-11 14:37:21.503 IST ERROR requestId=NA x-correlation-id=NA 17200 --- [ main] o.s.b.d.LoggingFailureAnalysisReporter :
***************************
APPLICATION FAILED TO START
***************************
Description:
An attempt was made to call a method that does not exist. The attempt was made from the following location:
io.github.resilience4j.spelresolver.autoconfigure.SpelResolverConfigurationOnMissingBean.spelResolver(SpelResolverConfigurationOnMissingBean.java:54)
The following method did not exist:
'io.github.resilience4j.spelresolver.SpelResolver io.github.resilience4j.spelresolver.configure.SpelResolverConfiguration.spelResolver(org.springframework.expression.spel.standard.SpelExpressionParser, org.springframework.core.ParameterNameDiscoverer, org.springframework.beans.factory.BeanFactory)'
The method's class, io.github.resilience4j.spelresolver.configure.SpelResolverConfiguration, is available from the following locations:
jar:file:/C:/Users/169576/.m2/repository/io/github/resilience4j/resilience4j-spring/1.6.0/resilience4j-spring-1.6.0.jar!/io/github/resilience4j/spelresolver/configure/SpelResolverConfiguration.class
The class hierarchy was loaded from the following locations:
io.github.resilience4j.spelresolver.configure.SpelResolverConfiguration: file:/C:/Users/169576/.m2/repository/io/github/resilience4j/resilience4j-spring/1.6.0/resilience4j-spring-1.6.0.jar
Can some one please help me to fix this issue.
Try version 1.7.0
<dependency>
<groupId>io.github.resilience4j</groupId>
<artifactId>resilience4j-core</artifactId>
<version>1.7.0</version>
</dependency>
<dependency>
<groupId>io.github.resilience4j</groupId>
<artifactId>resilience4j-spring-boot2</artifactId>
<version>1.7.0</version>
</dependency>
I have encountered this issue. I update also to version 1.7.0 but it not works.
I saw that the log information is show version to reference like that:
io.github.resilience4j.spelresolver.configure.SpelResolverConfiguration: file:/C:/Users/169576/.m2/repository/io/github/resilience4j/resilience4j-spring/1.6.0/resilience4j-spring-1.6.0.jar
We need only follow on log and update version to 1.6.0 means that same version in log

Correct the classpath of your application so that it contains a single, compatible version of org.elasticsearch.common.logging.Loggers

I'm getting following error while running my Spring boot app, I'm new to Spring boot and elastic search, please help to solve this issue.And attached my pom dependencies below.
Thanks in advance,
*************************** APPLICATION FAILED TO START ***************************
Description:
An attempt was made to call the method org.elasticsearch.common.logging.Loggers.getLogger(Ljava/lang/String;)Lorg/apache/logging/log4j/Logger; but it does not exist. Its class, org.elasticsearch.common.logging.Loggers, is available from the following locations:
jar:file:/C:/Users/Sudhakar/.m2/repository/org/elasticsearch/elasticsearch/6.6.2/elasticsearch-6.6.2.jar!/org/elasticsearch/common/logging/Loggers.class
It was loaded from the following location:
file:/C:/Users/Sudhakar/.m2/repository/org/elasticsearch/elasticsearch/6.6.2/elasticsearch-6.6.2.jar
Action:
Correct the classpath of your application so that it contains a single, compatible version of org.elasticsearch.common.logging.Loggers
Process finished with exit code 1
Maven dependencies:
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-to-slf4j</artifactId>
<version>2.11.1</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>1.7.24</version>
</dependency>
<dependency>
<groupId>org.elasticsearch</groupId>
<artifactId>elasticsearch</artifactId>
<version>6.6.2</version>
</dependency>
<dependency>
<groupId>org.elasticsearch.client</groupId>
<artifactId>transport</artifactId>
<version>6.6.2</version>
</dependency>
Spring Boot uses Elasticsearch 6.4 by default. By using 6.6.2 as the versions for two Elasticsearch modules you will have ended up with a mixture of the two versions. You should remove the <version> configuration in your pom. If you are able to use Spring Boot’s default version there’s nothing more to do. If you need to use 6.6.2 you should add an entry in your pom’s <properties>:
<elasticsearch.version>6.6.2</elasticsearch.version>

Adding javax.servlet-api dependency throws exception that org.slf4j.impl.StaticLoggerBinder faild to load but i don't use sl4j, i use thymeleaf

Basicaly title. I'm trying to run simple spring5 + thymeleaf project. If i don't add servlet-api i get an error that
cannot access javax.servlet.ServletException
But if i add servlet-api, project starts and works fine , but i get an error on startup:
SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".
SLF4J: Defaulting to no-operation (NOP) logger implementation
But i don't use sl4j, i use thymeleaf. How does servlet exception connected with sl4j and how should i manage it?
UPD
I understand that my question is wrong. But i need help with connected problem:
As someone suggested i added
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>1.7.5</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-log4j12</artifactId>
<version>1.7.5</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
</dependency>
But i still get Failed to load class "org.slf4j.impl.StaticLoggerBinder". exception. Any ideas?
UPD
as someone mentioned here this is a bug of ide
Add slf4j.jar in your dependency or your project. Spring internally use slf4j for its own logging.
I'm using IntelIj idea.
As someone sugested i added log4j and sl4j dependencies becouse servlet-api uses loging by default. And my exception that class is failed to load is just a bug of ide as it was mentioned in another question and everything including logging works fine.

Bean Validation with JBoss Errai

I want to make a GWT app with the Errai framework but I run in some problems with the Data Binding and Validation.
My pom.xml
<dependency>
<groupId>org.jboss.errai</groupId>
<artifactId>errai-validation</artifactId>
<version>${errai.version}</version>
</dependency>
<dependency>
<groupId>javax.validation</groupId>
<artifactId>validation-api</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>javax.validation</groupId>
<artifactId>validation-api</artifactId>
<classifier>sources</classifier>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-validator</artifactId>
<version>4.2.0.Final</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-validator</artifactId>
<version>4.2.0.Final</version>
<scope>provided</scope>
<classifier>sources</classifier>
</dependency>
My app.gwt.xml includes the Errai-Validation and HibernateValidator modules:
<inherits name="org.jboss.errai.validation.Validation" />
<inherits name="org.hibernate.validator.HibernateValidator" />
There are no unresolved dependencies I have already double checked this.
When I try to run the application with mvn gwt:run I'm getting the following error:
java.util.concurrent.ExecutionException: org.jboss.errai.ioc.rebind.ioc.exception.UnsatisfiedDependenciesException: #> org.jboss.errai.ui.nav.client.local.Navigation
- field org.jboss.errai.codegen.meta.MetaField:org.jboss.errai.ui.nav.client.local.Navigation.stateChangeEvent could not be satisfied for type: org.jboss.errai.ioc.client.lifecycle.api.StateChange
Message: can't resolve bean: org.jboss.errai.ioc.client.lifecycle.api.StateChange<java.lang.Object> ( #Default )
at java.util.concurrent.FutureTask.report(FutureTask.java:122)
at java.util.concurrent.FutureTask.get(FutureTask.java:188)
at org.jboss.errai.config.rebind.AsyncGenerators$FutureWrapper.get(AsyncGenerators.java:112)
at org.jboss.errai.config.rebind.AsyncGenerators$FutureWrapper.get(AsyncGenerators.java:86)
at org.jboss.errai.config.rebind.AbstractAsyncGenerator.startAsyncGeneratorsAndWaitFor(AbstractAsyncGenerator.java:100)
at org.jboss.errai.ioc.rebind.ioc.bootstrapper.IOCGenerator.generate(IOCGenerator.java:58)
at com.google.gwt.core.ext.IncrementalGenerator.generateNonIncrementally(IncrementalGenerator.java:40)
at com.google.gwt.dev.javac.StandardGeneratorContext.runGeneratorIncrementally(StandardGeneratorContext.java:657)
at com.google.gwt.dev.cfg.RuleGenerateWith.realize(RuleGenerateWith.java:41)
at com.google.gwt.dev.shell.StandardRebindOracle$Rebinder.rebind(StandardRebindOracle.java:79)
at com.google.gwt.dev.shell.StandardRebindOracle.rebind(StandardRebindOracle.java:276)
at com.google.gwt.dev.shell.ShellModuleSpaceHost.rebind(ShellModuleSpaceHost.java:141)
at com.google.gwt.dev.shell.ModuleSpace.rebind(ModuleSpace.java:595)
at com.google.gwt.dev.shell.ModuleSpace.rebindAndCreate(ModuleSpace.java:465)
at com.google.gwt.dev.shell.GWTBridgeImpl.create(GWTBridgeImpl.java:49)
at com.google.gwt.core.shared.GWT.create(GWT.java:57)
at com.google.gwt.core.client.GWT.create(GWT.java:85)
at org.jboss.errai.ioc.client.Container.bootstrapContainer(Container.java:64)
at org.jboss.errai.ioc.client.Container.onModuleLoad(Container.java:41)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at com.google.gwt.dev.shell.ModuleSpace.onLoad(ModuleSpace.java:406)
at com.google.gwt.dev.shell.OophmSessionHandler.loadModule(OophmSessionHandler.java:200)
at com.google.gwt.dev.shell.BrowserChannelServer.processConnection(BrowserChannelServer.java:526)
at com.google.gwt.dev.shell.BrowserChannelServer.run(BrowserChannelServer.java:364)
at java.lang.Thread.run(Thread.java:744)
Thats why the Bootstrap is failing and the application is throwing a onModuleLoad Exception and is not starting.
If I remove the 2 validation modules I'm able to start the application without any errors.
Im using the Errai Tutorial with version 3.0.1 FINAL.
Thanks for your help :)
EDIT:
I resolved the error by adding
<inherits name="org.jboss.errai.ui.nav.Navigation" />
to my app.gwt.xml but now I'm running into the next problem with this exception:
java.lang.RuntimeException: Deferred binding failed for 'org.jboss.errai.validation.client.ValidatorFactoryImpl$GwtValidator' (did you forget to inherit a required module?)
at com.google.gwt.dev.shell.GWTBridgeImpl.create(GWTBridgeImpl.java:53)
at com.google.gwt.core.shared.GWT.create(GWT.java:57)
at com.google.gwt.core.client.GWT.create(GWT.java:85)
at org.jboss.errai.validation.client.ValidatorFactoryImpl.createValidator(ValidatorFactoryImpl.java:11)
at com.google.gwt.validation.client.AbstractGwtValidatorFactory.getValidator(AbstractGwtValidatorFactory.java:90)
at org.jboss.errai.validation.client.ValidatorProvider.get(ValidatorProvider.java:37)
at org.jboss.errai.ioc.client.BootstrapperImpl$28.getInstance(BootstrapperImpl.java:432)
at org.jboss.errai.ioc.client.BootstrapperImpl$28.getInstance(BootstrapperImpl.java:1)
at org.jboss.errai.ioc.client.container.IOCDependentBean.getInstance(IOCDependentBean.java:96)
at org.jboss.errai.ioc.client.container.IOCDependentBean.getInstance(IOCDependentBean.java:87)
at org.jboss.errai.ioc.client.container.SyncToAsyncBeanManagerAdapter$1.getInstance(SyncToAsyncBeanManagerAdapter.java:148)
at org.jboss.errai.ui.nav.client.local.spi.GeneratedNavigationGraph$2.produceContent(GeneratedNavigationGraph.java:69)
at org.jboss.errai.ui.nav.client.local.Navigation.maybeShowPage(Navigation.java:304)
at org.jboss.errai.ui.nav.client.local.Navigation.navigate(Navigation.java:249)
at org.jboss.errai.ui.nav.client.local.Navigation.navigate(Navigation.java:230)
at org.jboss.errai.ui.nav.client.local.Navigation.navigate(Navigation.java:225)
at org.jboss.errai.ui.nav.client.local.Navigation.goTo(Navigation.java:191)
at org.jboss.errai.ui.nav.client.local.DefaultNavigationErrorHandler.handleError(DefaultNavigationErrorHandler.java:27)
at org.jboss.errai.ui.nav.client.local.Navigation.goTo(Navigation.java:193)
Is there another module that is missing?
I'm correct that Errai is creating the ValidationFactory and injecting the correct instance? So I don't have to create my own ValidationFactory like here:
GWT Validation Tutorial
Yes, that's correct. You don't have to create your own ValidationFactory. Errai will do that for you. You can simply #Inject a Validator.
I have prepared a version of the Errai tutorial using 3.0.1.Final that shows exactly that (following the instructions from the reference guide). I've put the project on GitHub.
The last error you pasted doesn't contain enough information to investigate why this is failing for you. However, you should see more error information in the devmode console.

Configuration jetty server logging

We would like to make jetty use log4j configuration for logging. I am using embedded jetty within spring based on this tutorial. I am followed this documentation to include all required slf4j and log4j dependencies in classpath.
Basically I added jetty-logging.properties to classpath with following configuration.
org.eclipse.jetty.util.log.class=org.eclipse.jetty.util.log.Slf4Log
org.eclipse.jetty.LEVEL=INFO
I also have log4j.properties in classpath
I have following maven dependencies to include required jars.
<dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
<version>${log4j.version}</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-log4j12</artifactId>
<version>${slf4j.log4j.version}</version>
</dependency>
<dependency>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-server</artifactId>
<version>${jetty.maven.version}</version>
</dependency>
<dependency>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-servlet</artifactId>
<version>8.1.9.v20130131</version>
</dependency>
But when I start up the jetty server via spring, the log output is always logged to StdErr and it's not logging to log file I configured in log4j.properties. Am I missing anything? Is there any debugging I can turn on to troubleshoot ..? How can I get this to work?
Though the answer to this question did help me find the answer, it took me a little bit more digging.
I was using Spring MVC with log4j. The following
public class LaunchServer {
private static final int SERVER_PORT = 8008;
public static void main(String[] args) throws Exception {
//Make sure you set the log before you start the server
Log.setLog(new Slf4jLog());
Server server = new Server();
ServerConnector connector = new ServerConnector(server);
connector.setPort(SERVER_PORT);
server.addConnector(connector);
WebAppContext wac = new WebAppContext();
wac.setWar("war");
wac.setContextPath("/");
wac.setMaxFormContentSize(5242880);
wac.setMaxFormKeys(100000);
wac.setClassLoader(Thread.currentThread().getContextClassLoader());
server.setHandler(wac);
server.setStopAtShutdown(true);
server.start();
}
}
In my log4j2.xml file under the <Loggers> I put
<Logger name="org.eclipse.jetty" level="debug" />
It worked well for me and avoided everything being logged to StdErr
I got this answered via jetty mailing list.

Resources