I am using following to execute spring and creating logs
java -jar AhMachine-0.0.1-SNAPSHOT.jar > c:\log.txt
but this creates a single log for lifetime.
Is there any way to split this log via commandline or spring boot?
I am using following to execute spring and creating logs
java -jar AhMachine-0.0.1-SNAPSHOT.jar > c:\log.txt
but this creates a single log for lifetime.
Is there any way to split this log via commandline or spring boot?
Not via command line, this can all be done inside the jar via rolling file appender:
https://www.baeldung.com/java-logging-rolling-file-appenders
If you cannot access the Jar no matter what see this comment:
https://stackoverflow.com/a/53395247/3942132
I haven't tested it but there should be a rotatelogs.exe process for windows as well.
java -jar AhMachine-0.0.1-SNAPSHOT.jar > c:\log.txt
will pipe the console output to a filejava -jar -Dlogging-file=c:\log.txt AhMachine-0.0.1-SNAPSHOT.jar
will output the internal configurated file appenders to a filejava -jar -Dlogging-file=c:\log.txt -Dlogging.file.max-size=4KB AhMachine-0.0.1-SNAPSHOT.jar
will output the internal configurated file appenders to a file will createlog.txt
files of max 4KB in size, a.gz
file is created of the older filesFor more complex configuration I would advise using a config-file like
spring-logback.xml
, you can easily specify the location of that file via the CLI-Dlogging.config=c:/log/config/spring-logback.xml