0

I would like to create a single log file for entire application. The log file name convection should includes date and time like this: MyLog_31122022_0915.log

Right now each class creates a new instance meaning a new log file. If I change the log file name convention, removing date and time, I get a single file, the problem is the the same file is used for each new run of the application.

How can it be done?

Rolf Kristensen
  • 17,785
  • 1
  • 51
  • 70
Tali
  • 1
  • 1
  • See also: https://stackoverflow.com/a/47802594/193178 - Ex. `fileName="MyLog_${processinfo:StartTime:format=ddMMyyyy_HHmm:cached=true}.log"` – Rolf Kristensen Aug 10 '22 at 14:48
  • See also: https://stackoverflow.com/a/72277631/193178 - Ex. `fileName="MyLog_${processinfo:StartTime:format=ddMMyyyy_HHmm:cached=true}.log"` – Rolf Kristensen Aug 10 '22 at 14:49

1 Answers1

1

You can use ${processinfo} to log process-starttime:

fileName="MyLog_${processinfo:StartTime:format=ddMMyyyy_HHmm:cached=true}.log"

You can adjust the DateTime-format to include seconds / milliseconds to make it more unique. Or you can include ${processid}:

fileName="MyLog_${processinfo:StartTime:format=ddMMyyyy_HHmmss:cached=true}_${processid}.log"
Rolf Kristensen
  • 17,785
  • 1
  • 51
  • 70