Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Is There a log4net Format? #126

Open
dprice opened this issue Oct 28, 2021 · 9 comments
Open

Is There a log4net Format? #126

dprice opened this issue Oct 28, 2021 · 9 comments

Comments

@dprice
Copy link

dprice commented Oct 28, 2021

I use Ideolog in Rider and we use log4net. I didn't see any default setting for log4net or even log4j that I could start with. Is this format available? I'm not exceptional at regex and would love a starting point! :)

@smirok
Copy link
Contributor

smirok commented Nov 7, 2024

Hi @dprice! Thank you for your request.

Could you please provide some examples of log4net logs, if this is still relevant to you?

@derek-price
Copy link

We have our log4net logs configured with this format:

        <appender name="DailyLogAppender" type="log4net.Appender.RollingFileAppender">
            <file value="SomeLogName.log" />
            <maxSizeRollBackups value="7" />
            <layout type="log4net.Layout.PatternLayout">
                <conversionPattern
                    value="%date [%thread] [%property{log4net:HostName}] [%level] %logger - %message %exception%newline" />
            </layout>
        </appender>

Here is a sample log that does not render:
UL.ImportManager.log

When I open it in Rider, I see this message first:
image

When I click on "Configure log formats" I see this:
image

@smirok
Copy link
Contributor

smirok commented Nov 11, 2024

Hi @derek-price! Default log4net pattern will be added in the formats directory soon, but as soon as you've customized log output, the following settings would work for you:

<State>
  <highlightingPatterns />
  <hiddenSubstrings />
  <parsingPatterns>
    <LogParsingPattern enabled="true" name="Log4net" pattern="^(\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2},\d{3})\s(\[\d+\])\s(\[\w+\])\s\[(.*?)\]\s(.*)\s-\s(.*)$" timePattern="yyyy-MM-dd HH:mm:ss,SSS" linePattern="^\d" timeId="0" severityId="3" categoryId="4" fullmatch="false" uuid="936fc789-bf72-4c0b-a53a-a723292afd47" />
  </parsingPatterns>
  <settingsVersion>9</settingsVersion>
</State>

The highlighted log file should look similar to
image

@smirok smirok closed this as completed Nov 11, 2024
@derek-price
Copy link

Where is this XML file located on Windows 11? Rider has so many folders and files scattered around the file system.

@smirok
Copy link
Contributor

smirok commented Nov 15, 2024

Please create the .xml file with the following content

<State>
  <highlightingPatterns />
  <hiddenSubstrings />
  <parsingPatterns>
    <LogParsingPattern enabled="true" name="Log4net" pattern="^(\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2},\d{3})\s(\[\d+\])\s(\[\w+\])\s\[(.*?)\]\s(.*)\s-\s(.*)$" timePattern="yyyy-MM-dd HH:mm:ss,SSS" linePattern="^\d" timeId="0" severityId="3" categoryId="4" fullmatch="false" uuid="936fc789-bf72-4c0b-a53a-a723292afd47" />
  </parsingPatterns>
  <settingsVersion>9</settingsVersion>
</State>

and import it using the button "Import" from the screen above.

@derek-price
Copy link

I've imported it, but nothing is getting highlighted unfortunately:
image

@smirok
Copy link
Contributor

smirok commented Nov 19, 2024

What version of the Ideolog plugin are you using?

@smirok smirok reopened this Nov 19, 2024
@derek-price
Copy link

Using JetBrains Rider 2024.3 and com.intellij.ideolog (243.21565.208)

@derek-price
Copy link

Anything I can provide to help with this? Logs, etc.? I tried loading a TeamCity build log and that did not have any highlighting other than https links:
image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants