Is there any way to put the std logs provided by the application and the errors to a span?
I wanted to put slf4j logs provided in quarkus and it should show up in jeager-Ui
Quarkus log information
application.properties
quarkus.http.port=8200
quarkus.swagger-ui.always-include=true
quarkus.jaeger.service-name=myservice
quarkus.jaeger.reporter-log-spans=true
quarkus.jaeger.log-trace-context=true
quarkus.jaeger.propagation=jaeger
quarkus.jaeger.sampler-type=const
quarkus.jaeger.sampler-param=1
quarkus.log.console.format=%d{HH:mm:ss} %-5p traceId=%X{traceId}, spanId=%X{spanId}, sampled=%X{sampled} [%c{2.}] (%t) %s%e%n
quarkus.log.handler.gelf.enabled=true
quarkus.log.handler.gelf.host=localhost
quarkus.log.handler.gelf.port=12201
Below are dependencies which I am using to achieve centralized log management(ELK).For that I am using guides provided by quarkus quarkus-centralized-log-managemt guide
pom.xml
<dependencies>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-resteasy</artifactId>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-junit5</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>io.rest-assured</groupId>
<artifactId>rest-assured</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-smallrye-opentracing</artifactId>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-hibernate-validator</artifactId>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-rest-client</artifactId>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-smallrye-openapi</artifactId>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-resteasy-jackson</artifactId>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-logging-gelf</artifactId>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-smallrye-metrics</artifactId>
</dependency>
</dependencies>
You can #Inject Tracer and add your own stuff in it.
But I thought that errors would be automatically logged in Jaeger, but I could be wrong.
After configuring your logs to accept Jaeger attributes like for ex :
quarkus.log.console.format=%d{HH:mm:ss} %-5p [%c{2.}] (%t)
[traceId=%X{traceId},spanId=%X{spanId},%X{sampled}] %s%e%n
Then you need to propagate Jaeger context to your logs through the below properties :
quarkus.jaeger.log-trace-context=true
quarkus.jaeger.propagation=jaeger
I had added a new gelf configuration property in my application.properties.By this we can send logs with traceId and spanId to ELK stack.
application.properties
quarkus.http.port=8200
quarkus.swagger-ui.always-include=true
quarkus.jaeger.service-name=myservice
quarkus.jaeger.reporter-log-spans=true //This can be excluded
quarkus.jaeger.propagation=jaeger //This can be excluded
quarkus.jaeger.sampler-type=const
quarkus.jaeger.sampler-param=1
quarkus.log.console.format=%d{HH:mm:ss} %-5p traceId=%X{traceId}, spanId=%X{spanId}, sampled=%X{sampled} [%c{2.}] (%t) %s%e%n
quarkus.log.handler.gelf.enabled=true
quarkus.log.handler.gelf.host=localhost
quarkus.log.handler.gelf.port=12201
quarkus.log.handler.gelf.include-full-mdc=true //newly added property
Related
I created a simple ( and almost empty ) spring boot project, I packaged into a jar and I deployed it on appengine.
But it doesn't start!
When I run https://.appspot.com I Have a 500 error page
I saw the database was created and the tables too, but there is something wrong into application
These are the last few lines of the log
Started VibesCoreApplication in 9.729 seconds (JVM running for 11.147)
Shutting down ExecutorService 'taskScheduler'
Closing JPA EntityManagerFactory for persistence unit 'default'
HikariPool-1 - Shutdown initiated...
HikariPool-1 - Shutdown completed.
this is a part of the pom file
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
<exclusions>
<!-- for GAE -->
<exclusion>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-tomcat</artifactId>
</exclusion>
</exclusions>
</dependency>
<!-- for GAE -->
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
<version>3.1.0</version>
<type>jar</type>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.google.apis</groupId>
<artifactId>google-api-services-sqladmin</artifactId>
<version>v1beta4-rev76-1.25.0</version>
</dependency>
<dependency>
<groupId>com.google.cloud.sql</groupId>
<artifactId>mysql-socket-factory</artifactId>
<version>1.0.2</version>
</dependency>
<dependency>
<groupId>com.google.api-client</groupId>
<artifactId>google-api-client</artifactId>
<version>1.23.0</version>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-gcp-starter</artifactId>
<version>LATEST</version>
</dependency>
<!-- JPA -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
<version>2.1.4.RELEASE</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.springframework.boot/spring-boot-starter-jdbc -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-jdbc</artifactId>
<version>2.2.2.RELEASE</version>
</dependency>
<!-- MySQL -->
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>8.0.17</version>
<scope>runtime</scope>
</dependency>
</dependencies>
this is the app.yaml file
runtime: java11
instance_class: F2
env: standard
network:
session_affinity: true
entrypoint: java -Xmx64m -jar target/vibes-core-0.4.0.jar
handlers:
- url: /(.*\.(gif|png|jpg|js|css|env))$
static_files: static/\1
upload: static/.*\.(gif|png|jpg)$
here there is the full logs
I was able to find a similar issue with yours here. The fact is that ( even this should not happen ) the configuration loading order may be broken.
In the post that I have sent you, the solution was removing the #EnableAutoConfiguration annotation.
While running my spring application i am getting lots of DEBUG log in my console tried most of the suggestions for this but none of it working, the dependency of my pom.xml is attached below.
In this project using Spring, hibernate.
Thanks.
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-batch</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-jdbc</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-frontend-jaxws</artifactId>
<version>${cxf.version}</version>
</dependency>
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-transports-http-jetty</artifactId>
<version>${cxf.version}</version>
</dependency>
<dependency>
<groupId>commons-lang</groupId>
<artifactId>commons-lang</artifactId>
<version>2.6</version>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-dbcp2</artifactId>
<version>2.1.1</version>
</dependency>
<dependency>
<groupId>com.amazonaws</groupId>
<artifactId>aws-lambda-java-core</artifactId>
<version>1.1.0</version>
</dependency>
<dependency>
<groupId>com.googlecode.lambdaj</groupId>
<artifactId>lambdaj</artifactId>
<version>2.3.3</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>1.7.25</version>
</dependency>
This happened to me after including Liquibase in my project. Had to explicitly set logging provider for JBoss inside project.yml:
org:
jboss:
logging:
provider: jdk
I wanted to use EclipseLink for Spring Boot in my Spring Boot project. I was able to configure everything. But when I was implementing I found one strange thing. I had to include EclipseLink as implementation for JPA in my pom.xml. My first try was:
<groupId>org.eclipse.persistence</groupId>
<artifactId>eclipselink</artifactId>
<version>RELEASE</version>
However, when I was trying to run my code each time I received an exception:
Unable to create a Configuration, because no Bean Validation provider could be found. Add a provider like Hibernate Validator (RI) to your classpath.
I was searching on their website https://wiki.eclipse.org/EclipseLink/Maven and it is written there that dependency to EclipseLink should contain all the other implementation.
I tried to change dependency in pom.xml to:
<groupId>org.eclipse.persistence</groupId>
<artifactId>org.eclipse.persistence.jpa</artifactId>
<version>RELEASE</version>
And everything works as expected. Does this dependency contains more than EclipseLink? Does not EclipseLink dependency contains implementation for bean validation?
Does this dependency contains more than EclipseLink?
Yes, if you see the pom.xml of org.eclipse.persistence.jpa dependency you'll find those dependencies:
<dependencies>
<dependency>
<groupId>org.eclipse.persistence</groupId>
<artifactId>javax.persistence</artifactId>
<version>2.2.0</version>
<type>jar</type>
<scope>compile</scope>
<optional>false</optional>
</dependency>
<dependency>
<groupId>org.eclipse.persistence</groupId>
<artifactId>org.eclipse.persistence.asm</artifactId>
<version>2.7.0</version>
<type>jar</type>
<scope>compile</scope>
<optional>false</optional>
</dependency>
<dependency>
<groupId>org.eclipse.persistence</groupId>
<artifactId>org.eclipse.persistence.antlr</artifactId>
<version>2.7.0</version>
<type>jar</type>
<scope>compile</scope>
<optional>false</optional>
</dependency>
<dependency>
<groupId>org.glassfish</groupId>
<artifactId>javax.json</artifactId>
<version>1.0.4</version>
<type>jar</type>
<scope>compile</scope>
<optional>false</optional>
</dependency>
<dependency>
<groupId>org.eclipse.persistence</groupId>
<artifactId>org.eclipse.persistence.jpa.jpql</artifactId>
<version>2.7.0</version>
<type>jar</type>
<scope>compile</scope>
<optional>false</optional>
</dependency>
<dependency>
<groupId>org.eclipse.persistence</groupId>
<artifactId>org.eclipse.persistence.core</artifactId>
<version>2.7.0</version>
<type>jar</type>
<scope>compile</scope>
<optional>false</optional>
</dependency>
</dependencies>
Does not EclipseLink dependency contains implementation for bean validation?
You can check this link Bean validation
I would like to have all the internal Springboot log messages directed to log4j so that the messages follow my log4j properties (i.e. they go to the console and my log4j file using my layout).
I attempted to configure Springboot to use only log4j logging per this guide: http://spring.io/blog/2009/12/04/logging-dependencies-in-spring/
I have successfully setup log4j to log to the console and to file when using a log4j logger object.
However, it appears that Springboot is still using slf4j when it logs internally. I tried removing the slf4j dependencies, but Springboot fails to startup with a missing class exception.
How can I direct all the internal Springboot logging to log4j?
Have you tried this from the official docs?
http://docs.spring.io/spring-boot/docs/1.2.2.RELEASE/reference/htmlsingle/#howto-configure-log4j-for-logging
Basically you have to exclude the logback stuff that comes by default with the starter poms.
Quoted here for reference:
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<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>
If you are using spring-boot, I recommend following the spring documentation, which I found easier than your reference.
I have log4j working, and it prints messages like:
[2015-03-06 15:34:54 INFO ] [main] [tomcat.TomcatEmbeddedServletContainer] Tomcat initialized with port(s): 8080 (http)
Not sure if that's what you mean by internal messages.
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot</artifactId>
<version>1.1.4.RELEASE</version>
<exclusions>
<exclusion>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-logging</artifactId>
</exclusion>
</exclusions>
</dependency>
<!-- add slf4j interfaces to classpath this is for log4j -->
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>1.6.4</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-log4j12</artifactId>
<version>1.6.4</version>
<scope>runtime</scope>
</dependency>
<!-- add log4j to classpath -->
<!-- does the logging -->
<dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
<version>1.2.16</version>
</dependency>
Add log4j.properties under resources
log4j.rootLogger=INFO, Console, File
# Direct log messages to stdout
log4j.appender.Console=org.apache.log4j.ConsoleAppender
log4j.appender.Console.Target=System.out
log4j.appender.Console.layout=org.apache.log4j.PatternLayout
log4j.appender.Console.layout.ConversionPattern=%d{yyyy-MM-dd HH:mm:ss} [%t] %-5p %c{1}:%L - %m%n
log4j.appender.File=org.apache.log4j.RollingFileAppender
log4j.appender.File.append=true
log4j.appender.File.file=/tmp/projectdir/logfile-ws.log
log4j.appender.File.threshold=INFO
log4j.appender.File.layout=org.apache.log4j.PatternLayout
log4j.appender.File.layout.ConversionPattern=%d{yyyy-MM-dd HH:mm:ss} [%t] %-5p %c{1}:%L - %m%n
log4j.appender.File.MaxFileSize=100MB
log4j.appender.File.MaxBackupIndex=1
I have been trying to integrate Spring with Hibernate Search but getting different exceptions with different versions.
In my pom.xml I have following dependencies
<dependency>
<groupId>org.apache.struts</groupId>
<artifactId>struts2-core</artifactId>
<version>2.1.8.1</version>
</dependency>
<dependency>
<groupId>org.apache.struts</groupId>
<artifactId>struts2-spring-plugin</artifactId>
<version>2.1.8.1</version>
</dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>5.1.9</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring</artifactId>
<version>2.5.6</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-web</artifactId>
<version>2.5.6</version>
</dependency>
<dependency>
<groupId>asm</groupId>
<artifactId>asm-all</artifactId>
<version>3.3</version>
</dependency>
<dependency>
<groupId>asm</groupId>
<artifactId>asm</artifactId>
<version>3.3</version>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-core</artifactId>
<version>3.6.7.Final</version>
</dependency>
<dependency>
<groupId>org.apache.struts</groupId>
<artifactId>struts2-convention-plugin</artifactId>
<version>2.1.8.1</version>
</dependency>
<dependency>
<groupId>org.apache.struts</groupId>
<artifactId>struts2-tiles-plugin</artifactId>
<version>2.1.8.1</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
<version>3.0.1</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
<version>1.2.15</version>
</dependency>
<dependency>
<groupId>joda-time</groupId>
<artifactId>joda-time</artifactId>
<version>2.0</version>
</dependency>
<dependency>
<groupId>commons-configuration</groupId>
<artifactId>commons-configuration</artifactId>
<version>1.6</version>
</dependency>
<dependency>
<groupId>com.jgeppert.struts2.jquery</groupId>
<artifactId>struts2-jquery-plugin</artifactId>
<version>3.5.1</version>
</dependency>
<dependency>
<groupId>com.jgeppert.struts2.jquery</groupId>
<artifactId>struts2-jquery-grid-plugin</artifactId>
<version>3.5.1</version>
</dependency>
<dependency>
<groupId>com.jgeppert.struts2.jquery</groupId>
<artifactId>struts2-jquery-richtext-plugin</artifactId>
<version>3.5.1</version>
</dependency>
<dependency>
<groupId>com.jgeppert.struts2.jquery</groupId>
<artifactId>struts2-jquery-tree-plugin</artifactId>
<version>3.5.1</version>
</dependency>
<dependency>
<groupId>com.jgeppert.struts2.jquery</groupId>
<artifactId>struts2-jquery-mobile-plugin</artifactId>
<version>3.5.1</version>
</dependency>
I have also tried to get the actual version of hibernate (3.2.0 Final) from my tests so that I can easily compare the compatibility of hiberante search with my application's hiberante version.
String hibernateVersion = org.hibernate.annotations.common.Version.VERSION;
System.out.println("Hibernate Version: "+ hibernateVersion);
But whenever I just add these lines into my pom file
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-search</artifactId>
<version>3.1.0.GA</version>
</dependency>
and try to deploy my application then it gives me an exception
ERROR org.springframework.web.context.ContextLoader.initWebApplicationContext:215 - Context initialization failed org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory' defined in ServletContext resource ....
....
....
Caused by: java.lang.NoSuchMethodError: org.hibernate.util.SoftLimitMRUCache.<init>(I)V
Mandatory:
Change all Struts2 jars from 2.1.8.1 to 2.3.16
Change struts2-jquery-plugin from 3.5.1 to 3.7.0 (or it won't work with 2.3.16, only with lower versions)
Suggested:
Upgrade Hibernate to 4.x
Upgrade Spring to 3.x
If possible, use Hibernate as JPA2 implementation, instead of using it as raw Hibernate (old way). Then you will discover that Spring is no longer needed (for persistence at least), especially if you are using JAVA EE 6.
P.S: you will need to upgrade also Apache Commons and other shared libraries according to the latest version, just use Maven Repository to get the proper version numbers.