JetBrains / ideolog

Interactive viewer for '.log' files.
MIT License
254 stars 55 forks source link

Support for serilog #43

Open Xarkam opened 6 years ago

Xarkam commented 6 years ago

Hello, I tried to add templates for serilog support, but I can't do it. I make a log formats pattern: Message pattern: ^(?s)([^\[]*)\[([^\]]*)\]([^\]]*)(.*)$ Message start pattern: ^\d Time format: yyyy-MM-dd HH:mm:ss.SSS

I create a Patterns: ^\s*i(nformation)?\s*$ in hightlight line mode.

But nothing is highlighted.

Here a piece of a log file:

2018-08-17 11:00:27.983 +02:00 [Information] Executing Configure action '"Security.ServiceConfiguration.ActivateAuthentication"'
2018-08-17 11:00:28.019 +02:00 [Information] Executing Configure action '"ExtCore.Mvc.Actions.UseStaticFilesAction"'
2018-08-17 11:00:28.026 +02:00 [Information] Executing Configure action '"ExtCore.Mvc.Actions.UseMvcAction"'
2018-08-17 11:00:28.051 +02:00 [Debug] Compatibility switch "AllowInputFormatterExceptionMessages" in type "MvcJsonOptions" is using default value False
2018-08-17 11:00:28.301 +02:00 [Debug] Compatibility switch "AllowCombiningAuthorizeFilters" in type "MvcOptions" is using default value False
2018-08-17 11:00:28.301 +02:00 [Debug] Compatibility switch "AllowBindingHeaderValuesToNonStringModelTypes" in type "MvcOptions" is using default value False
2018-08-17 11:00:28.302 +02:00 [Debug] Compatibility switch "AllowValidatingTopLevelNodes" in type "MvcOptions" is using default value False
2018-08-17 11:00:28.302 +02:00 [Debug] Compatibility switch "InputFormatterExceptionPolicy" in type "MvcOptions" is using default value AllExceptions
2018-08-17 11:00:28.302 +02:00 [Debug] Compatibility switch "SuppressBindingUndefinedValueToEnumType" in type "MvcOptions" is using default value False
2018-08-17 11:00:28.318 +02:00 [Debug] Compatibility switch "AllowAreas" in type "RazorPagesOptions" is using default value False
2018-08-17 11:00:28.318 +02:00 [Debug] Compatibility switch "AllowMappingHeadRequestsToGetHandler" in type "RazorPagesOptions" is using default value False
2018-08-17 11:00:28.697 +02:00 [Debug] Compatibility switch "SuppressTempDataAttributePrefix" in type "MvcViewOptions" is using default value False
2018-08-17 11:00:28.769 +02:00 [Debug] Registered model binder providers, in the following order: ["Microsoft.AspNetCore.Mvc.ModelBinding.Binders.BinderTypeModelBinderProvider", "Microsoft.AspNetCore.Mvc.ModelBinding.Binders.ServicesModelBinderProvider", "Microsoft.AspNetCore.Mvc.ModelBinding.Binders.BodyModelBinderProvider", "Microsoft.AspNetCore.Mvc.ModelBinding.Binders.HeaderModelBinderProvider", "Microsoft.AspNetCore.Mvc.ModelBinding.Binders.FloatingPointTypeModelBinderProvider", "Microsoft.AspNetCore.Mvc.ModelBinding.Binders.EnumTypeModelBinderProvider", "Microsoft.AspNetCore.Mvc.ModelBinding.Binders.SimpleTypeModelBinderProvider", "Microsoft.AspNetCore.Mvc.ModelBinding.Binders.CancellationTokenModelBinderProvider", "Microsoft.AspNetCore.Mvc.ModelBinding.Binders.ByteArrayModelBinderProvider", "Microsoft.AspNetCore.Mvc.ModelBinding.Binders.FormFileModelBinderProvider", "Microsoft.AspNetCore.Mvc.ModelBinding.Binders.FormCollectionModelBinderProvider", "Microsoft.AspNetCore.Mvc.ModelBinding.Binders.KeyValuePairModelBinderProvider", "Microsoft.AspNetCore.Mvc.ModelBinding.Binders.DictionaryModelBinderProvider", "Microsoft.AspNetCore.Mvc.ModelBinding.Binders.ArrayModelBinderProvider", "Microsoft.AspNetCore.Mvc.ModelBinding.Binders.CollectionModelBinderProvider", "Microsoft.AspNetCore.Mvc.ModelBinding.Binders.ComplexTypeModelBinderProvider"]
2018-08-17 11:00:28.812 +02:00 [Information] Executing UseMvc action '"Barebone.Actions.UseMvcActions"'

What did I do wrong?

rodion-m commented 4 years ago

++ For Serilog support

Trigun27 commented 4 years ago

agree!

Trigun27 commented 4 years ago

Find the solution

image

image

OliverZott commented 1 year ago

Find the solution

image

image

Could you please provide the xml for your solution?

marpe commented 1 year ago

These settings worked for me after restarting the IDE:

Message pattern: ^(\d{4}-\d{2}-\d{2}\s\d{2}:\d{2}:\d{2}\.\d{3}\s[\+\-]\d{2}:\d{2})\s+\[(\w+)\]\s+(\S+:\d+)\s+\[(\S+)\]\s+(.*)$ Message start pattern: ^\d Time format: yyyy-MM-dd HH:mm:ss.SSS XXX Time capture group: 1 Severity capture group: 2 Category capture group: 4

Then I added the dates and severity as separate Patterns to get some highlighting... don't get why you would have to do it twice, but ok

Here's the XML

<State>
  <highlightingPatterns>
    <LogHighlightingPattern enabled="true" pattern="^\s*(e(rror)?|severe)\s*$" action="HIGHLIGHT_LINE" fg="-39836" bold="true" italic="false" stripe="true" uuid="de2d3bb2-78c9-4beb-835e-d483c35c07b6" />
    <LogHighlightingPattern enabled="true" pattern="^\s*w(arn(ing)?)?\s*$" action="HIGHLIGHT_LINE" fg="-6329600" bold="true" italic="false" stripe="false" uuid="11ff1574-2118-4722-905a-61bec89b079e" />
    <LogHighlightingPattern enabled="true" pattern="^\s*i(nfo)?\s*$" action="HIGHLIGHT_LINE" fg="-10316203" bold="false" italic="false" stripe="false" uuid="5e882ebc-2179-488b-8e1a-2fe488636f36" />
    <LogHighlightingPattern enabled="true" pattern="^\d{4}-\d{2}-\d{2}\s\d{2}:\d{2}:\d{2}\.\d{3}\s[\+\-]\d{2}:\d{2}" action="HIGHLIGHT_FIELD" fg="-10373377" bold="false" italic="false" stripe="false" uuid="4a787cef-27f8-4d40-b132-4291e5a439c2" />
  </highlightingPatterns>
  <hiddenSubstrings />
  <parsingPatterns>
    <LogParsingPattern enabled="true" name="Pipe-separated" pattern="^(?s)([^|]*)\|([^|]*)\|([^|]*)\|(.*)$" timePattern="HH:mm:ss.SSS" linePattern="^\d" timeId="0" severityId="1" categoryId="2" fullmatch="false" uuid="b5772998-bf1e-4d9d-ab41-da0b86451163" />
    <LogParsingPattern enabled="true" name="IntelliJ IDEA" pattern="^([^\[]+)(\[[\s\d]+])\s*(\w*)\s*-\s*(\S*)\s*-(.+)$" timePattern="yyyy-MM-dd HH:mm:ss,SSS" linePattern="^\d" timeId="0" severityId="2" categoryId="3" fullmatch="false" uuid="8a0e8992-94cb-4f4c-8be2-42b03609626b" />
    <LogParsingPattern enabled="true" name="TeamCity build log" pattern="^\[([^]]+)](.):\s*(\[[^]]+])?(.*)$" timePattern="HH:mm:ss" linePattern="^\[" timeId="0" severityId="1" categoryId="2" fullmatch="false" uuid="e9fa2755-8390-42f5-a41e-a909c58c8cf9" />
    <LogParsingPattern enabled="true" name="Whim" pattern="^(\d{4}-\d{2}-\d{2}\s\d{2}:\d{2}:\d{2}\.\d{3}\s[\+\-]\d{2}:\d{2})\s+\[(\w+)\]\s+(\S+:\d+)\s+\[(\S+)\]\s+(.*)$" timePattern="yyyy-MM-dd HH:mm:ss.SSS XXX" linePattern="^\d" timeId="0" severityId="1" categoryId="3" fullmatch="false" uuid="7a50932c-fdf4-4c5f-beae-08bcde54b678" />
  </parsingPatterns>
  <settingsVersion>7</settingsVersion>
  <lastAddedDefaultFormat>b5772998-bf1e-4d9d-ab41-da0b86451163,8a0e8992-94cb-4f4c-8be2-42b03609626b,e9fa2755-8390-42f5-a41e-a909c58c8cf9</lastAddedDefaultFormat>
  <errorStripeModel>heatmap</errorStripeModel>
  <readonlySizeThreshold>16</readonlySizeThreshold>
  <highlight_links>true</highlight_links>
</State>
vniehues commented 11 months ago

Just in case someone else stumbles across this thread and needs help with a completely basic serilog implementation:

Bildschirmfoto 2023-11-22 um 13 30 47 Bildschirmfoto 2023-11-22 um 13 30 58

big code blocks for easy copying

Message pattern:

^(?s)([^\[]*)\[([^\]]*)\]([^\]]*)(.*)$

Message start pattern:

^\d

Time format:

yyyy-MM-dd HH:mm:ss.SSS XXX

Patterns:

^\s*ERR?\s*$
^\s*WRN?\s*$
^\s*INF?\s*$
^\s*DBG?\s*$

Just for reference, this is how I implemented serilog in an asp.net core project:

Log.Logger = new LoggerConfiguration()
    .MinimumLevel.Debug()
    .WriteTo.Async(a => a.File($"Logs/{Assembly.GetExecutingAssembly().GetName().Name}.log", rollingInterval: RollingInterval.Day))
    .WriteTo.Async(a => a.Console())
    .CreateLogger();
builder.Logging.ClearProviders();
builder.Logging.AddSerilog();

It's kind of the most basic implementation there is but it's a good starting point and works with the settings up top :)

andriibratanin commented 2 months ago

Hey, just created the related PR: https://github.com/JetBrains/ideolog/pull/192