Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Structured logging not working #2252

Closed
deman-Innotractor opened this issue Apr 29, 2022 · 3 comments
Closed

Structured logging not working #2252

deman-Innotractor opened this issue Apr 29, 2022 · 3 comments

Comments

@deman-Innotractor
Copy link

Expected behavior

Want to see structured logging in Azure.

Actual behavior

No structured logging at all, only the information. Maybe it is related to #2251

To Reproduce

@slf4j
log.info("Test {}, {}", kv("test1", "a"), v("test2", "b"));

Sample Application

If applicable, provide a sample application which reproduces the issue.

System information

Please provide the following information:

  • SDK Version: 3.2.11 (also 3.2.10)
  • OS type and version: Windows 11
  • Application Server type and version (if applicable): (local)
  • Using spring-boot? yes
  • Additional relevant libraries (with version, if applicable): Lombok.

POM.xml

<dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter</artifactId>
            <version>2.6.7</version>
        </dependency>

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-validation</artifactId>
            <version>2.6.7</version>
        </dependency>
        <dependency>
            <groupId>com.microsoft.azure</groupId>
            <artifactId>applicationinsights-core</artifactId>
            <version>2.6.4</version>
        </dependency>
        <dependency>
            <groupId>io.opentelemetry</groupId>
            <artifactId>opentelemetry-api</artifactId>
            <version>1.10.0</version>
        </dependency>
        <dependency>
            <groupId>io.opentelemetry</groupId>
            <artifactId>opentelemetry-extension-annotations</artifactId>
            <version>1.10.0</version>
        </dependency>
        <dependency>
            <groupId>io.opentelemetry</groupId>
            <artifactId>opentelemetry-semconv</artifactId>
            <version>1.10.0-alpha</version>
        </dependency>
        <dependency>
            <groupId>io.micrometer</groupId>
            <artifactId>micrometer-core</artifactId>
            <version>1.8.5</version>
        </dependency>

        <dependency>
            <groupId>ch.qos.logback</groupId>
            <artifactId>logback-core</artifactId>
            <version>1.2.11</version>
        </dependency>
        <dependency>
            <groupId>net.logstash.logback</groupId>
            <artifactId>logstash-logback-encoder</artifactId>
            <version>7.1.1</version>
        </dependency>

Logs

logback-spring.xml:

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
	<springProfile name="default">
		<appender name="stdout" class="ch.qos.logback.core.ConsoleAppender">
			<encoder class="net.logstash.logback.encoder.LoggingEventCompositeJsonEncoder">
				<providers>
					<timestamp>
						<fieldName>timestamp</fieldName>
						<timeZone>UTC</timeZone>
					</timestamp>
					<loggerName>
						<fieldName>logger</fieldName>
					</loggerName>
					<logLevel>
						<fieldName>level</fieldName>
					</logLevel>
					<threadName>
						<fieldName>thread</fieldName>
					</threadName>
					<nestedField>
						<fieldName>mdc</fieldName>
						<providers>
							<mdc />
						</providers>
					</nestedField>
					<stackTrace>
						<fieldName>stackTrace</fieldName>
						<!-- maxLength - limit the length of the stack trace -->
						<throwableConverter class="net.logstash.logback.stacktrace.ShortenedThrowableConverter">
							<maxDepthPerThrowable>200</maxDepthPerThrowable>
							<maxLength>14000</maxLength>
							<rootCauseFirst>true</rootCauseFirst>
						</throwableConverter>
					</stackTrace>
					<message />
					<throwableClassName>
						<fieldName>exceptionClass</fieldName>
					</throwableClassName>
				</providers>
			</encoder>
		</appender>
	</springProfile>
	<root level="INFO">
		<appender-ref ref="stdout" />
	</root>

</configuration>

Console log:

{"timestamp":"2022-04-29T10:32:47.099Z","logger":"com.innotractor.leshan.server.LeshanInnoInstance","level":"INFO","thread":"restartedMain","mdc":{},"message":"Test test1=a, b"}

Screenshots

image

@ghost ghost added the Needs: Triage 🔍 label Apr 29, 2022
@trask
Copy link
Member

trask commented Apr 29, 2022

hi @deman-Innotractor! can you see if the discussion here helps? open-telemetry/opentelemetry-java-instrumentation#5496

@deman-Innotractor
Copy link
Author

I did read through that thread, and if I'm not mistaken it is in the last line:

Ok, now it makes sense to me.
So, at the time, isn't possible to implement my use case by using encoders with extended capabilities (like the json format capability).

So it isn't possible (yet) I think? I can't see the json that is being send to Azure Application Insights, to confirm that is okay.

@trask
Copy link
Member

trask commented May 3, 2022

@deman-Innotractor this is correct, I have opened open-telemetry/opentelemetry-java-instrumentation#5969 to track this upstream

@trask trask closed this as completed May 3, 2022
@ghost ghost locked as resolved and limited conversation to collaborators Jun 3, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants