How can i change that format of the log to file action → append timestamp
timestamp format in log action
Hi
If I understand your query right, you looking to change the log format. you can achieve it by changing the property line “<Property name="FormatPatternSingleLine">...</Property>” in the bot agent config files which are located at “C:\Program Files\Automation Anywhere\Bot Agent\config”
nodemanager-logging.xml
botlauncher-logging.xml
triggerlistener-logging.xml
autologinhelper-logging.xml
You can customize the log format pattern according to your requirements as mentioned here- https://logging.apache.org/log4j/1.2/apidocs/org/apache/log4j/PatternLayout.html
![Collaborator Bronze Badge](https://uploads-us-west-2.insided.com/automationanywhere-en/attachment/fee7f4b5-b93b-4ad9-b9d0-d7e4b4be4c9a_thumb.png)
Hi
Thank you for the reply.
To my knowledge, these are system generated log files. I want to change the format of the “append timestamp” in the “log to file action” in the bot editor. Please use the picture as reference.
![](https://uploads-us-west-2.insided.com/automationanywhere-en/attachment/bcb01595-099e-4527-bde3-1d23a0b536ed.png)
The current log timestamp format is “(M/d/yyyy h:m:s a)”
Example:
(9/28/2023 2:48:31 PM) XXXXXX - BOT STARTED
I want to change it to change it to “yyyy-MM-dd HH:mm:ss”
I tried using the Date:toSting action, but it is not convenient. It also has the tendency to add milliseconds with no specified decimal point cutoff. I have to define the conversion log format manually every time to go around this behavior. Plus, if adds an extra line of code for every time I want to log. We don’t want to use log files with different timestamp lengths. It makes debugging harder.
![](https://uploads-us-west-2.insided.com/automationanywhere-en/attachment/e0e0be3b-c838-4578-96fe-7fedc638f1f1.png)
Finally, Is there a way for me to define a log level (debug, warning, info,….) per “log to file” action? I am currently adding the level by hand.
Hi
Kindly try the below option,
- Uncheck the append timestamp
- add the below code into the Enter text to log $System:Year.Number:toString$-$System:Month.Number:toString$-$System:day.Number:toString$ $System:hour.Number:toString$:$System:Minute.Number:toString$:$System:Second.Number:toString$
Following above steps, you can log the details with required format. Would you like to add any additional info you can add it as well.
Example
: $System:Year.Number:toString$-$System:Month.Number:toString$-$System:day.Number:toString$ $System:hour.Number:toString$:$System:Minute.Number:toString$:$System:Second.Number:toString$ $PRCS-ProcessName$ ORB3 Process - Started
![](https://uploads-us-west-2.insided.com/automationanywhere-en/attachment/19d2115e-f5e3-4f90-b406-7ed6f0247301.png)
![Collaborator Bronze Badge](https://uploads-us-west-2.insided.com/automationanywhere-en/attachment/fee7f4b5-b93b-4ad9-b9d0-d7e4b4be4c9a_thumb.png)
$System:Year.Number:toString$-$System:Month.Number:toString$-$System:day.Number:toString$ $System:hour.Number:toString$:$System:Minute.Number:toString$:$System:Second.Number:toString$ $PRCS-ProcessName$ ORB3 Process - Started
Hi
Thank you for your reply.
We are aware of the solution you present and thank you for pointing it out to us. We are looking for a more elegant solution. We do not want our developers to add this much boilerplate code on every log call. We would prefer to use the built in checkbox instead since it already exists.
Also, please note that in rare situations your code will return the wrong time since you are fetching each part of it on it’s own. It is better to fetch the whole date from System:Date and then apply a Date::toString() action on it. This will guarantee a consistent result.
Our main question still stands however. Is there a way to control the behavior of the “log to file” → “append timestamp” action?
![Peer Advisor Badge](https://uploads-us-west-2.insided.com/automationanywhere-en/attachment/64798f59-b217-4548-b0f5-de4ed6d06e8a_thumb.png)
Log to file action checks for system’s regional short date and short time settings to generate the time format. If you change these in system, it will reflect in your log files.
You can change them from following registry keys:
Location: Computer\HKEY_CURRENT_USER\Control Panel\International
Keys:
-
sTimeFormat
- sShortDate
![](https://uploads-us-west-2.insided.com/automationanywhere-en/attachment/454085a8-236b-4355-9484-b0fd03b26ff2.png)
I suggest looking into package SDK to build something as per your requirements.
AA pre built logging action is trivial. Even though log variables options was added recently, it still cant log complex/ nested variables like list, dictionary, table, record or list of dictionaries etc. You need to convert to string through legacy package(which AA discourages in new bot builds) and is difficult to read/not sure if actual escape character or data. Also it lacks file rollover based on size/time etc.
Reply
Enter your E-mail address. We'll send you an e-mail with instructions to reset your password.