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

allow inline stacktrace generation #807

Closed

Conversation

MarneusCalgarXP
Copy link

@MarneusCalgarXP MarneusCalgarXP commented May 10, 2022

allow inline stacktrace generation, adding an inline option to net.logstash.logback.stacktrace.ShortenedThrowableConverter

ie:

    <conversionRule conversionWord="stack"
                       converterClass="net.logstash.logback.stacktrace.ShortenedThrowableConverter" />

    <property name="STACKTRACE_PATTERN" value="%stack{full,40,500,rootFirst,inline}"/>
    

    <property name="CONSOLE_LOG_PATTERN" value="%d%d{Z} %-5level [%15.15t] %-40.40logger{39} [%20.20marker] - %replace(%msg){'\n', '\\\\n'} || mdc=[%mdc] ${STACKTRACE_PATTERN} %n"/>
    
    <appender name="CONSOLE" class="ch.qos.logback.core.ConsoleAppender">
		<encoder>
			<pattern>${CONSOLE_LOG_PATTERN}</pattern>
		</encoder>
	</appender>

result in a single line :
2022-05-10 11:06:46,859+0200 ERROR [ main] com.example.demo.DemoApplication [ ] - failure || mdc=[] java.lang.IllegalAccessException: a\n at com.example.demo.DemoApplication.lambda$run$0(DemoApplication.java:40)\n at o.springframework.boot.SpringApplication.callRunner(SpringApplication.java:777)\n ... 3 common frames omitted\nWrapped by: java.lang.IllegalStateException: Failed to execute CommandLineRunner\n at o.springframework.boot.SpringApplication.callRunner(SpringApplication.java:780)\n at o.springframework.boot.SpringApplication.callRunners(SpringApplication.java:761)\n at o.springfr...\n

(useful for rsyslog or fluentd when you don't want to use json format)

@brenuart
Copy link
Collaborator

I haven't add the time to fully review your PR yet... Sorry about that.
In the meantime I have approved your contribution. A build will now be triggered every time you submit a change. You may have to rebase your work to pickup the latest changes I'm afraid, or the build will keep failing because of issues not related to your work.

@codecov
Copy link

codecov bot commented May 18, 2022

Codecov Report

Merging #807 (3b920ac) into main (81f8493) will decrease coverage by 0.00%.
The diff coverage is 100.00%.

❗ Current head 3b920ac differs from pull request most recent head ec50ba4. Consider uploading reports for the commit ec50ba4 to get more accurate results

@@             Coverage Diff              @@
##               main     #807      +/-   ##
============================================
- Coverage     70.87%   70.86%   -0.01%     
- Complexity     1250     1253       +3     
============================================
  Files           167      167              
  Lines          4796     4802       +6     
  Branches        497      498       +1     
============================================
+ Hits           3399     3403       +4     
- Misses         1151     1152       +1     
- Partials        246      247       +1     
Impacted Files Coverage Δ
...ogback/stacktrace/ShortenedThrowableConverter.java 77.73% <100.00%> (+0.55%) ⬆️
...ck/appender/AbstractLogstashTcpSocketAppender.java 69.23% <0.00%> (-0.52%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 81f8493...ec50ba4. Read the comment docs.

@brenuart
Copy link
Collaborator

Hi @MarneusCalgarXP, it would be nice if you could also add some information/documentation about this new feature in the relevant section of the README.md.

@MarneusCalgarXP
Copy link
Author

Hi @MarneusCalgarXP, it would be nice if you could also add some information/documentation about this new feature in the relevant section of the README.md.

done

brenuart added a commit that referenced this pull request May 19, 2022
@brenuart
Copy link
Collaborator

I made some additional cosmetic changes to your PR. It has been merged manually, reason why I'm simply closing the PR.
Thanks for your contribution.

@brenuart brenuart closed this May 19, 2022
@MarneusCalgarXP MarneusCalgarXP deleted the stacktrace_inline_option branch May 23, 2022 07:55
@MarneusCalgarXP
Copy link
Author

I made some additional cosmetic changes to your PR. It has been merged manually, reason why I'm simply closing the PR. Thanks for your contribution.

thank you for merging it ;-)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants