I am working in a core java application and i recently added springintegration for TCP connection with my server.
I am using my own logger so I need to disable the spring logging. I have no logback xml, only an xml to have spring integration tcp connection.
How can I disable spring logging?
I already tried some stuffs in spring integration docs but doesn't work.
The spring logs are logging those for no use I already catches the errors and logs them but spring again does it of no use.
This is the file i am having for logging
# Logging Options
log.level = INFO
log.path = ./log/
log.console = yes
log.backup.path = ./log/bkp/
log.rotate.pattern = yyyyMMddHH
log.org.springframework=OFF
# RawLog Logging Options
rawlog.path = ./raw_log/
rawlog.backup.path = ./raw_log/bkp/
rawlog.rotate.pattern = yyyyMMddHH
Related
I have an angular application using a tracing library to trace each operation (user bouton click).
This application after SPA is loaded sends a list of traces in the request body to the backend microservice to log them.
In the backend microservice, I am using the spring boot 2.3.7, the spring cloud Hoxton.SR9 and logback 1.2.3.
This is the method:
#PostMapping("/traces")
public ResponseEntity<List<Trace>> addTrace(#RequestBody List<Trace> traces) {
traces.forEach(trace -> {
RtLog log = RtLog.builder.parentSpanId(trace.getParentId()).traceId(trace.getTraceId()).spanId(trace.getSpanId)).operationName(trace.getOperationName())
.businessJourney(trace.getBaggages().getBusinessJourney())
.componentId(trace.getBaggages().getComponentId()).componentType(trace.getBaggages().getComponentType())
.sessionId(trace.getBaggages().getSessionId()).userId(trace.getBaggages().getUserId())
.duration(trace.getDuration())
.time(!Null.isNullOrEmpty(datetime) ? datetime.format(DateTimeFormatter.ofPattern(TIMESTAMP_PATTERN))
: EMPTY)
.tags(trace.getTags()).build();
logger.info("spa_log", StructuredArguments.fields(log));
An example of traces send by the application:
The problem is when logging the information, the spring sleuth adds on the log another traceId and spanId that I don't need, and it causes conflict with the correct Ids.
So how can I override the traceId and spanId or is it possible to disable the tracing in this method?
There is the traceContext or brave Tracing but I found that I can builder a new trace but I didn't find a way to change the current trace.
I am trying to integrate New Relic with Spring Boot actuator. Most of the tutorials and response in StackOverflow itself suggest to use New Relic Java Agent but as per Spring Boot documentation installing Java Agent is not mandatory (unless I misunderstood something) also checked this. So, here is my application.properties currently.
management.metrics.export.newrelic.enabled = true
management.metrics.export.newrelic.api-key = <API_KEY>
management.metrics.export.newrelic.account-id = <ACCOUNT_ID>
logging.level.io.micrometer.newrelic=TRACE
management.metrics.export.newrelic.step=30s
and in the log I am seeing
2021-01-11 12:05:18.315 DEBUG 44635 --- [trics-publisher] i.m.n.NewRelicInsightsApiClientProvider : successfully sent 73 metrics to New Relic.
Based on this logs it looks like it is sending logs. But I have no idea where to see this logs. Ideally I would like to pass app name as well so that I can differentiate metric by app name and preferably by env as well later. Any suggestions?
To add "app name" and "env" to your metrics, you just need to configure the MeterFilter with the common tags:
#Configuration
public class MetricsConfig {
#Bean
public MeterFilter commonTagsMeterFilter(#Value("...") appName, #Value("...") env) {
return MeterFilter.commonTags(Tag.of("app name", appName), Tag.of("env", env);
}
}
Setting the following property you should be able to see what metrics are being sent to NewRelic:
logging.level.io.micrometer.newrelic=TRACE
I am trying to set up Jaeger to collect traces from a spring boot application. When my app starts up, I am getting this warning message
warn io.jaegertracing.internal.senders.SenderResolver - No sender factories available. Using NoopSender, meaning that data will not be sent anywhere!
I use this method to get the jaeger tracer
#Bean
Tracer jaegerTracer(#Value(defaulTraceName) String service)
{
SamplerConfiguration samplerConfig = SamplerConfiguration.fromEnv().withType("const").withParam(1);
ReporterConfiguration reporterConfig = ReporterConfiguration.fromEnv().withLogSpans(true);
Configuration config = new Configuration(service).withSampler(samplerConfig).withReporter(reporterConfig);
return config.getTracer();
}
I have manually instrumented the code, but no traces show up in the jaeger UI. I have been stuck on this problem for a few days now and would appreciate any help given!
In my pom file, I have dependencies on jaeger-core and opentracing-api
Solved by adding dependency in pom file on jaeger-thrift.
I'm using Jest at enter link description here in my spring boot application.
Then I created the client with the example code :
JestClientFactory factory = new JestClientFactory();
factory.setHttpClientConfig(new HttpClientConfig
.Builder("http://myhost:9200")
.multiThreaded(true)
JestClient client = factory.getObject();
Everything is fine. I can use this client to do all the queries I want. Happy till now.
Then the problem, when the application starts up, ElasticsearchJestHealthIndicator class is auto-initialized. But the problem is I don't know where to set the config that it will need, so it uses the default value as http://localhost:9200, which leads me to this problem:
WARN [on(2)-127.0.0.1] s.b.a.h.ElasticsearchJestHealthIndicator : Health check failed
io.searchbox.client.config.exception.CouldNotConnectException: Could not connect to http://localhost:9200
at io.searchbox.client.http.JestHttpClient.execute(JestHttpClient.java:70)
at io.searchbox.client.http.JestHttpClient.execute(JestHttpClient.java:60)
Can someone show me how to properly config it , or turn it off ?
A quick search in the reference documentation shows that Spring Boot will configure for you a JestClient (you can just inject it anywhere you need), and that the following configuration properties apply:
spring.elasticsearch.jest.uris=http://search.example.com:9200
spring.elasticsearch.jest.read-timeout=10000
spring.elasticsearch.jest.username=user
spring.elasticsearch.jest.password=secret
See here for more on this.
The Jest client has been deprecated as well, since both Elasticsearch and Spring Data Elasticsearch provide official support for REST clients.
See https://docs.spring.io/spring-boot/docs/current/reference/html/spring-boot-features.html#boot-features-elasticsearch
I have a java app that is running on spring boot.
I'm using tika which in turn uses pdfbox.
I'm using logback as my logging implementation with slf4j.
I know that pdfbox uses apache commons logging.
I'm trying to disable the change the logging level to FATAL like so
<logger name="org.apache.pdfbox" level="FATAL"/>
The problem is that it still doesn't change the level.
I've run this with a debugger. I'm inspecting the logger that pdfbox uses and the results are
result = SLF4JLocationAwareLog
name = org.apache.pdfbox.util.PDFStreamEngine
logger.level = null
logger.loggerContext = ch.qos.logback.classic.LoggerContext[default]
By logger context, I understand that it is indeed using logback, but the configs are not present.
I'll answer my own question and hope that someone will find it useful.
The reason that the logger.level was null is because I didn't specify anything, so it got it from the parent logger. The FATAL didn't work because the highest level is not FATAL but ERROR.
http://logback.qos.ch/apidocs/ch/qos/logback/classic/Level.html
When I changed it to error everything worked as expected.