4

I'm using spring-boot-admin-ui to monitor my web applications. Logging is configured with log4j2, in log4j2-spring.xml.

Question: how can I show those logfiles in admin-ui? As far as I read it could display logback out of the box. But how can I enable log4j2 support, if possible at all?

The logfile is like:

<Loggers>
   <Root level="DEBUG">
        <AppenderRef ref="APP" />
        <AppenderRef ref="XML" />
        <AppenderRef ... />
    </Root>
</Loggers>

I'd like to see the last X lines of the logfiles in admin-ui, or being able to directly download them via ui.

membersound
  • 81,582
  • 193
  • 585
  • 1,120

3 Answers3

6

you need to make sure the /logfile-endpoint from spring boot actguator is active. For example by setting the logging.file property. You can also configure a non-boot managed logfile by using endpoints.logfile.external-file.

joshiste
  • 2,638
  • 1
  • 14
  • 19
  • OK, setting the `endpoints.logfile.external-file` to one the log4j created files worked. I though it would be auto-discovered, and one could see all logfiles created. But in fact currently it's only possible to set a hardlink to one of them. – membersound Jul 16 '17 at 10:07
  • 1
    `endpoints.logfile.external-file` is deprecated use `management.endpoint.logfile.external-file` – chiranjeevigk Dec 11 '19 at 07:53
1

It is enough just to add a property file to the application.properties

"logging.file.name=logging.txt".

P.S. The name of the file and its extension to test.

Procrastinator
  • 2,526
  • 30
  • 27
  • 36
Simon
  • 11
  • 3
0

Both options mentioned in other answers need:

  1. 'logfile' actuator endpoint exposing
management:
  endpoints:
    web:
      exposure:
         include: logfile
  endpoint:
    logfile: 
      enabled: true
  1. adding log file in section 'logging':
logging:
  file:
    name: logging.txt # ant name
bvn13
  • 154
  • 11