JetBrains / ideolog

Interactive viewer for '.log' files.
MIT License
251 stars 54 forks source link

"Log Format Not Recognized" Warning Message, Pattern Applied, Logs Colored, Warning Cleared, OG Regex Not Working #188

Open aaronhunter1088 opened 1 month ago

aaronhunter1088 commented 1 month ago

Hi Jetbrains,

I noticed the above mentioned warning message while reviewing my log file one day and decided to fix the issue rather than clicking "Hide this notification," or "Don't show again".

I am using Log4j2 to print to the console and my log file, and this is my pattern I am using --> [%-6level] %d{MM-dd-yyyy hh:mm:ss.SSS a} [Method:%M] %c:%L :: %msg%n (1*) (2*) (1) For the console, the pattern changes from [%-6level] to %highlight{%-6level} (FILE: log4j2.properties.txt)

Using regex101.com, I was able to create a regex and verified that it matches my logs --> Regex:

Screenshot 2024-05-17 at 3 46 07 AM

I set the regex as my message pattern, but it still did not clear the warning or color my logs in my log file (the console is being colored because of the highlighting).
My message pattern is --> ^(\[[A-Z]{4,6}\])\s?(\d{2}.\d{2}.\d{4})\s?(\d{2}\:\d{2}\:\d{2}.\d{3}\s?[A-Z]{2})\s?\[.\]\s?-\s?(.)\n$ My message start pattern is --> ^\[ My time format is --> MM-dd-yyyy hh:mm:ss.SSS a

IntelliJ Log Highlighting -->

Screenshot 2024-05-17 at 5 06 48 AM

IntelliJ Log Patterns -->

Screenshot 2024-05-17 at 3 54 54 AM

When I checked my log file, it was still not coloring my logs as I expected. (2**) I removed the brackets around the log level in my log4j2.properties file, making my pattern become the following: %-6level %d{MM-dd-yyyy hh:mm:ss.SSS a} [%c:%M:%L] - %msg%n

After making this change, I noticed my log file began to color my logs, but the warning message remained. File logs -->

Screenshot 2024-05-17 at 3 51 05 AM

When I attempt to find my message pattern using Command + F (Find), using the regex matching option, I had to change my pattern in order for it to match all logs --> From --> ^(\[[A-Z]{4,6}\])\s?(\d{2}.\d{2}.\d{4})\s?(\d{2}\:\d{2}\:\d{2}.\d{3}\s?[A-Z]{2})\s?[.]\s?-\s?(.)\n$ To --> ^(\[[A-Z].{4,6}\])(?s)(.*)$

New Values --> My message pattern is --> ^(\[[A-Z].{4,6}\])(?s)(.*)$ My message start pattern is --> ^\[ My time format is --> MM-dd-yyyy hh:mm:ss.SSS a

Find Regex in Log File -->

Screenshot 2024-05-17 at 4 11 46 AM

Find Regex in Console logs -->

Screenshot 2024-05-17 at 4 34 01 AM

Since my log file no longer contains the brackets around the level, I changed my message pattern and message start pattern one final time to be --> Message pattern --> ^(\w)(?s)(.)$ Message start pattern --> ^\w My time format is --> MM-dd-yyyy hh:mm:ss.SSS a

Using these final values still worked and colored my logs, and after a lot of hard work, the warning message also disappeared. Since I see others are having troubles with this, I am still posting this in hopes that it helps anyone else who may be struggling.

Warning Message Cleared:

Screenshot 2024-05-17 at 4 48 47 AM

Working IntelliJ Log Patterns -->

Screenshot 2024-05-17 at 4 32 10 AM
wp4nuv commented 1 month ago

This happens to me, but it is inversed. The monolog format regexp works in regex-101, and PHPStorm doesn't complain about the format, but the highlighting fails to save the color. The saved color for the existing examples is reflected in the Action column, but for custom ones, you can select the color, but once you hit OK, nothing is saved. Selecting BOLD or italic is reflected in the Action column.