Home
%3CLINGO-SUB%20id%3D%22lingo-sub-973947%22%20slang%3D%22en-US%22%3EWindows%20Containers%20Log%20Monitor%20Opensource%20Release%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-973947%22%20slang%3D%22en-US%22%3E%3CP%3E%3CFONT%20size%3D%224%22%3ETL%3BDR%3A%20Windows%20Containers%20Log%20Monitor%20is%20opensource%20released%20%3CA%20href%3D%22https%3A%2F%2Fgithub.com%2Fmicrosoft%2Fwindows-container-tools%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noopener%20noreferrer%20noopener%20noreferrer%22%3Eon%20Github.%3C%2FA%3E%3C%2FFONT%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CFONT%20size%3D%224%22%3EIn%20this%20%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2FContainers%2FAnnouncing-Container-Log-Tooling-and-Survey%2Fba-p%2F536088%22%20target%3D%22_blank%22%20rel%3D%22noopener%22%3Eblog%20post%3C%2FA%3E%20we%20announced%20our%20efforts%20to%20improve%20the%20tooling%20experience%20for%20containers.%20The%20first%20step%20in%20this%20journey%20was%20with%20a%20log%20tool%20concept%20we%20demoed%20during%20our%20container%20session%20at%20%2F%2Fbuild.%20This%20demo%20was%20met%20with%20clear%20excitement%20from%20attendees%20and%20interest%20from%20the%20community.%20After%20gathering%20customer%20feedback%2C%20we%20set%20out%20to%20bring%20this%20tool%20to%20production%20quality%20and%20make%20it%20open%20source%20available%20for%20our%20Windows%20Containers%20users.%3C%2FFONT%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CFONT%20size%3D%224%22%3EToday%2C%20we%20are%20happy%20to%20announce%20the%20opensource%20release%20of%20the%20Windows%20Container%20Log%20Monitor%2C%20%3CA%20href%3D%22https%3A%2F%2Fgithub.com%2Fmicrosoft%2Fwindows-container-tools%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noopener%20noreferrer%20noopener%20noreferrer%22%3Enow%20available%20on%20Github%3C%2FA%3E!%20This%20blog%20offers%20a%20deep%20dive%20into%20the%20architecture%20and%20usage%20of%20the%20tool.%3C%2FFONT%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CFONT%20size%3D%224%22%3ETo%20recap%2C%20unlike%20Linux%20applications%20that%20log%20to%20STDOUT%2C%20Windows%20applications%20log%20to%20Windows%20log%20locations%20such%20as%20ETW%2C%20Event%20Log%2C%20and%20custom%20log%20files.%20Since%20many%20container%20ecosystem%20logging%20solutions%20are%20built%20to%20pull%20from%20the%20STDOUT%20pipeline%20as%20standard%20with%20Linux%2C%20Windows%20containers%20app%20logs%20historically%20have%20not%20been%20accessible%20via%20these%20solutions.%20The%20Log%20Monitor%20bridges%20this%20gap%20between%20Windows%20log%20locations%20and%20STDOUT%2C%20as%20depicted%20in%20the%20diagram%20below.%20The%20scope%20of%20the%20Log%20Monitor%20tool%20is%20to%20bridge%20Windows%20application%20logs%20to%20the%20STDOUT%20pipeline.%3C%2FFONT%3E%3C%2FP%3E%0A%3CDIV%20id%3D%22tinyMceEditorclipboard_image_2%22%20class%3D%22mceNonEditable%20lia-copypaste-placeholder%22%3E%26nbsp%3B%3C%2FDIV%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-center%22%20style%3D%22width%3A%20999px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Fgxcuf89792.i.lithium.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F153458i42EF3FF648257AC3%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20alt%3D%22ignitelogblog.png%22%20title%3D%22ignitelogblog.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CFONT%20size%3D%224%22%3EThe%20Log%20Monitor%20tool%20consists%20of%20two%20primary%20elements%3A%20LogMonitor.exe%20and%20LogMonitorConfig.json.%20Like%20the%20%2F%2Fbuild%20demo%20POC%2C%20the%20Log%20Monitor%20is%20authored%20with%20an%20observer%2C%20publisher-subscriber%20design%20pattern%3B%20however%2C%20instead%20of%20subscribing%20to%20hardcoded%20log%20source%20providers%20as%20in%20the%20original%20concept%2C%20the%20Log%20Monitor%20is%20configured%20to%20subscribe%20to%20a%26nbsp%3B%20set%20of%20sources%20defined%20by%20the%20user%20in%20the%20Log%20Monitor%20Config%20file.%3C%2FFONT%3E%3C%2FP%3E%0A%3CP%3E%3CFONT%20size%3D%224%22%3EThe%20log%20sources%20supported%20by%20the%20Log%20Monitor%20tool%20include%3A%3C%2FFONT%3E%3C%2FP%3E%0A%3CUL%3E%0A%3CLI%3E%3CFONT%20size%3D%224%22%3EETW%3C%2FFONT%3E%3C%2FLI%3E%0A%3CLI%3E%3CFONT%20size%3D%224%22%3EEvent%20Logs%3C%2FFONT%3E%3C%2FLI%3E%0A%3CLI%3E%3CFONT%20size%3D%224%22%3ELog%20files%3C%2FFONT%3E%3C%2FLI%3E%0A%3C%2FUL%3E%0A%3CP%3E%3CFONT%20size%3D%224%22%3ENote%20that%20these%20sources%20differ%20from%20the%20original%20concept%2C%20which%20collected%20Perf%20Counters%20and%20did%20not%20collect%20Event%20Logs.%20From%20feedback%20we%20concluded%20that%20Perf%20Counters%2C%20while%20useful%2C%20fall%20closer%20to%20system%20metrics%20than%20application%20logs%2C%20and%20were%20thus%20out%20of%20scope%20for%20this%20release.%20Additionally%2C%20the%20Log%20Monitor%20tool%20does%20not%20monitor%20the%20lifecycle%20of%20services%20within%20the%20container%20as%20in%20the%20original%20concept%2C%20but%20instead%20provides%20a%20nesting%20pattern%20so%20users%20can%20define%20their%20own%20service%20monitor%20or%20desired%20application.%3C%2FFONT%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CFONT%20size%3D%224%22%3EThe%20log%20tool%20is%20supported%20for%20Windows%2C%20Server%20Core%2C%20and%20Nano%20images.%3C%2FFONT%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CU%3E%3CSTRONG%3E%3CFONT%20size%3D%224%22%3EUsage%3C%2FFONT%3E%3C%2FSTRONG%3E%3C%2FU%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CFONT%20size%3D%224%22%3EA%20key%20point%20of%20feedback%20we%20received%20at%20%2F%2Fbuild%20and%20in%20the%20post-build%20survey%20was%20that%20the%20entry%20point-only%20solution%20restricts%20users%20from%20using%20their%20own%20app%20as%20the%20entry%20point%20process.%20We%20mitigate%20this%20with%20several%20options%20on%20usage%3A%3C%2FFONT%3E%3C%2FP%3E%0A%3COL%3E%0A%3CLI%3E%3CFONT%20size%3D%224%22%3EThe%20Log%20Monitor%20tool%20can%20be%20used%20as%20the%20SHELL%20or%20the%20ENTRYPOINT%3C%2FFONT%3E%3C%2FLI%3E%0A%3CLI%3E%3CFONT%20size%3D%224%22%3EAs%20either%20the%20SHELL%20or%20ENTRYPOINT%2C%20another%20application%20can%20be%20indicated%20as%20a%20parameter%20to%20the%20Log%20Monitor%20tool%20as%20a%20nested%20process.%20The%20Log%20Monitor%20tool%20will%20spin%20up%20that%20process%20and%20monitor%20its%20STDOUT%20so%20that%20it%20also%20continues%20to%20show%20up%20in%20the%20container%20STDOUT.%20This%20mitigates%20the%20foreground%2Fbackground%20process%20issue%20that%20existed%20in%20the%20original%20concept.%3C%2FFONT%3E%3C%2FLI%3E%0A%3C%2FOL%3E%0A%3CP%3E%3CFONT%20size%3D%224%22%3EAn%20example%20dockerfile%20for%20the%20SHELL%20usage%20pattern%20(with%20nesting)%3A%3C%2FFONT%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CPRE%20class%3D%22lia-code-sample%20language-markup%22%3E%3CCODE%3EFROM%20mcr.mt.com%2Fwindows%2Fservercore%3A1903%0A%23LogMonitor%20directory%20contains%20LogMonitor.exe%20and%20LogMonitorConfig.json%20file%0ACOPY%20LogMonitor%2F%20C%3A%2FLogMonitor%0AWORKDIR%20%2FLogMonitor%0ASHELL%20%5B%22C%3A%5C%5CLogMonitor%5C%5CLogMonitor.exe%22%2C%20%22cmd%22%2C%20%22%2FS%22%2C%20%22%2FC%22%5D%0ACMD%20c%3A%5Cwindows%5Csystem32%5Cping.exe%20-n%2020%20localhost%3C%2FCODE%3E%3C%2FPRE%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CFONT%20size%3D%224%22%3EAn%20example%20dockerfile%20for%20the%20ENTRYPOINT%20usage%20pattern%20(with%20nesting)%3A%3C%2FFONT%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CPRE%20class%3D%22lia-code-sample%20language-markup%22%3E%3CCODE%3EFROM%20mcr.microsoft.com%2Fwindows%2Fservercore%3A1903%0A%23LogMonitor%20directory%20contains%20LogMonitor.exe%20and%20LogMonitorConfig.json%20file%0ACOPY%20LogMonitor%2F%20C%3A%2FLogMonitor%20%20%20%20%0AWORKDIR%20%2FLogMonitor%0AENTRYPOINT%20C%3A%5CLogMonitor%5CLogMonitor.exe%20%20c%3A%5Cwindows%5Csystem32%5Cping.exe%20-n%2020%20localhost%3C%2FCODE%3E%3C%2FPRE%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CFONT%20size%3D%224%22%3ENote%20that%20in%20the%20SHELL%20usage%20pattern%20the%20CMD%2FENTRYPOINT%20instruction%20should%20be%20specified%20in%20the%20SHELL%20form%20and%20not%20exec%20form.%20When%20exec%20form%20of%20the%20CMD%2FENTRYPOINT%20instruction%20is%20used%2C%20SHELL%20is%20not%20launched%2C%20and%20the%20Log%20Monitor%20tool%20will%20not%20be%20launched%20inside%20the%20container.%3C%2FFONT%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CFONT%20size%3D%224%22%3EAdditionally%2C%20if%20you%20are%20building%20from%20an%20image%20that%20pre-defines%20an%20entrypoint%20(i.e.%20an%20IIS%20image%20that%20pre-defines%20%3CA%20href%3D%22https%3A%2F%2Fgithub.com%2Fmicrosoft%2FIIS.ServiceMonitor%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noopener%20noreferrer%20noopener%20noreferrer%22%3EIIS.ServiceMonitor%3C%2FA%3E%20as%20the%20entry%20point)%2C%20you%20must%20redefine%20the%20entrypoint%20in%20your%20dockerfile%2C%20either%20as%20the%20Log%20Monitor%20if%20you%20are%20using%20the%20ENTRYPOINT%20pattern%2C%20or%20as%20the%20pre-defined%20entrypoint.%20If%20you%20do%20not%20redefine%20the%20ENTRYPOINT%20of%20your%20dockerfile%20and%20are%20using%20the%20SHELL%20usage%20pattern%2C%20the%20Log%20Monitor%20tool%20will%20not%20work.%20This%20is%20because%20the%20SHELL%20is%20tied%20to%20the%20entrypoint%20definition.%3C%2FFONT%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CFONT%20size%3D%224%22%3EBoth%20example%20usages%20wrap%20the%20ping.exe%20application.%20Other%20applications%20such%20as%20IIS.ServiceMonitor%20can%20be%20nested%20with%20Log%20Monitor%20in%20a%20similar%20fashion%3A%3C%2FFONT%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CPRE%20class%3D%22lia-code-sample%20language-markup%22%3E%3CCODE%3ECOPY%20LogMonitor.exe%20LogMonitorConfig.json%20C%3A%5CLogMonitor%5C%0AWORKDIR%20%2FLogMonitor%0ASHELL%20%5B%22C%3A%5C%5CLogMonitor%5C%5CLogMonitor.exe%22%2C%20%22powershell.exe%22%5D%0A%20%0A%23%20Start%20IIS%20Remote%20Management%20and%20monitor%20IIS%0AENTRYPOINT%20%20%20%20%20%20Start-Service%20WMSVC%3B%20%60%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20C%3A%5CServiceMonitor.exe%20w3svc%3B%0A%3C%2FCODE%3E%3C%2FPRE%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CU%3E%3CSTRONG%3E%3CFONT%20size%3D%224%22%3EConfiguration%3C%2FFONT%3E%3C%2FSTRONG%3E%3C%2FU%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CFONT%20size%3D%224%22%3EA%20sample%20Log%20Monitor%20Config%20file%20would%20be%20structured%20as%20follows%3A%3C%2FFONT%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CPRE%20class%3D%22lia-code-sample%20language-markup%22%3E%3CCODE%3E%7B%0A%20%20%22LogConfig%22%3A%20%7B%0A%20%20%20%20%22sources%22%3A%20%5B%0A%20%20%20%20%20%20%7B%0A%20%20%20%20%20%20%20%20%22type%22%3A%20%22EventLog%22%2C%0A%20%20%20%20%20%20%20%20%22startAtOldestRecord%22%3A%20true%2C%0A%20%20%20%20%20%20%20%20%22eventFormatMultiLine%22%3A%20false%2C%0A%20%20%20%20%20%20%20%20%22channels%22%3A%20%5B%0A%20%20%20%20%20%20%20%20%20%20%7B%0A%20%20%20%20%20%20%20%20%20%20%20%20%22name%22%3A%20%22system%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%22level%22%3A%20%22Error%22%0A%20%20%20%20%20%20%20%20%20%20%7D%0A%20%20%20%20%20%20%20%20%5D%0A%20%20%20%20%20%20%7D%2C%0A%20%20%20%20%20%20%7B%0A%20%20%20%20%20%20%20%20%22type%22%3A%20%22File%22%2C%0A%20%20%20%20%20%20%20%20%22directory%22%3A%20%22c%3A%5C%5Cinetpub%5C%5Clogs%22%2C%0A%20%20%20%20%20%20%20%20%22filter%22%3A%20%22*.log%22%2C%0A%20%20%20%20%20%20%20%20%22includeSubdirectories%22%3A%20true%0A%20%20%20%20%20%20%7D%2C%0A%20%20%20%20%20%20%7B%0A%20%20%20%20%20%20%20%20%22type%22%3A%20%22ETW%22%2C%0A%20%20%20%20%20%20%20%20%22providers%22%3A%20%5B%0A%20%20%20%20%20%20%20%20%20%20%7B%0A%20%20%20%20%20%20%20%20%20%20%20%20%22providerName%22%3A%20%22IIS%3A%20WWW%20Server%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%22ProviderGuid%22%3A%20%223A2A4E84-4C21-4981-AE10-3FDA0D9B0F83%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%22level%22%3A%20%22Information%22%0A%20%20%20%20%20%20%20%20%20%20%7D%2C%0A%20%20%20%20%20%20%20%20%20%20%7B%0A%20%20%20%20%20%20%20%20%20%20%20%20%22providerName%22%3A%20%22Microsoft-Windows-IIS-Logging%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%22ProviderGuid%20%22%3A%20%227E8AD27F-B271-4EA2-A783-A47BDE29143B%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%22level%22%3A%20%22Information%22%20%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%22keywords%22%3A%20%220xFF%22%0A%20%20%20%20%20%20%20%20%20%20%7D%0A%20%20%20%20%20%20%20%20%5D%0A%20%20%20%20%20%20%7D%0A%20%20%20%20%5D%0A%20%20%7D%0A%7D%3C%2FCODE%3E%3C%2FPRE%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CFONT%20size%3D%224%22%3EIn%20the%20config%20file%20there%20are%20the%20three%20log%20types%20you%20can%20configure%20the%20Log%20Monitor%20tool%20to%20pull%20from%3A%3C%2FFONT%3E%3C%2FP%3E%0A%3CUL%3E%0A%3CLI%3E%3CFONT%20size%3D%224%22%3E%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fwindows%2Fwin32%2Feventlog%2Fevent-logging%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noopener%20noreferrer%20noopener%20noreferrer%22%3EEvent%20Logs%3C%2FA%3E.%20The%20event%20log%20provides%20a%20standard%2C%20centralized%20way%20for%20apps%20and%20the%20OS%20to%20record%20important%20software%20and%20hardware%20events.%20Each%20event%20is%20in%20a%20structured%20data%20format%2C%20which%20makes%20it%20easy%20to%20parse%20for%20event%20log%20view%20panes%20(i.e.%20Event%20Viewer)%20or%20examine%20with%20a%20programmatic%20interface.%20The%20configuration%20file%20supports%20the%20following%20fields%3A%3C%2FFONT%3E%3C%2FLI%3E%0A%3CUL%3E%0A%3CLI%3E%3CFONT%20size%3D%224%22%3EstartAtOldestRecord.%20This%20Boolean%20field%20indicates%20whether%20the%20Log%20Monitor%20tool%20should%20output%20event%20logs%20from%20the%20start%20of%20the%20container%20boot%20(true)%20or%20from%20the%20start%20of%20the%20Log%20Monitor%20tool%20itself%20(false).%3C%2FFONT%3E%3C%2FLI%3E%0A%3CLI%3E%3CFONT%20size%3D%224%22%3EeventFormatMultiLine.%20This%20Boolean%20field%20indicates%20whether%20the%20Log%20Monitor%20should%20format%20the%20logs%20to%20STDOUT%20as%20multi-line%20or%20single%20line.%20If%20set%20true%2C%20the%20tool%20does%20not%20format%20the%20event%20messages%20to%20a%20single%20line%20(and%20thus%20event%20messages%20can%20span%20multiple%20lines).%20If%20set%20to%20false%2C%20the%20tool%20formats%20the%20event%20log%20messages%20to%20a%20single%20line%20and%20removes%20new%20line%20characters.%20Many%20container%20tools%20that%20build%20upon%20docker%20logs%20and%20the%20STDOUT%20pipe%20assume%20each%20log%20entry%20is%20on%20a%20single%20line%20as%20Linux%20event%20messages%20are%20typically%20single%20line.%3C%2FFONT%3E%3C%2FLI%3E%0A%3CLI%3E%3CFONT%20size%3D%224%22%3E%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fwindows%2Fwin32%2Fwes%2Fdefining-channels%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noopener%20noreferrer%20noopener%20noreferrer%22%3Echannels%3C%2FA%3E.%20%26nbsp%3BA%20channel%20is%20a%20sync%20that%20collects%20events.%20The%20%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fwindows-server%2Fadministration%2Fwindows-commands%2Fwevtutil%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noopener%20noreferrer%20noopener%20noreferrer%22%3Ewevutil%20tool%3C%2FA%3E%20can%20be%20used%20to%20enumerate%20channels%20via%20the%20command%20%E2%80%9Cwevutil%20el.%E2%80%9D%3C%2FFONT%3E%3C%2FLI%3E%0A%3CUL%3E%0A%3CLI%3E%3CFONT%20size%3D%224%22%3EName.%20Name%20of%20the%20event%20channel%3C%2FFONT%3E%3C%2FLI%3E%0A%3CLI%3E%3CFONT%20size%3D%224%22%3ELevel.%20This%20string%20field%20specifies%20the%20verboseness%20of%20the%20events%20collected.%20Possible%20values%20in%20ascending%20order%20of%20verbosity%20are%20Critical%2C%20Error%2C%20Warning%2C%20Information%2C%20and%20Verbose.%20Verbose%20encompasses%20Critical%2C%20Error%2C%20and%20Warning%2C%20and%20Information.%3C%2FFONT%3E%3C%2FLI%3E%0A%3C%2FUL%3E%0A%3C%2FUL%3E%0A%3CLI%3E%3CFONT%20size%3D%224%22%3ECustom%20Log%20File.%20Many%20apps%20log%20to%20custom%20app%20log%20files.%20Some%20services%20such%20as%20the%20IIS%20service%20also%20log%20to%20files%20in%20well-known%20locations.%20The%20Log%20Monitor%20tool%20can%20be%20configured%20to%20parse%20through%20custom%20log%20files%20and%20bridge%20these%20entries%20to%20STDOUT.%20The%20configuration%20file%20supports%20the%20following%20fields%3A%3C%2FFONT%3E%3C%2FLI%3E%0A%3CUL%3E%0A%3CLI%3E%3CFONT%20size%3D%224%22%3Edirectory.%20This%20string%20field%20indicates%20the%20directory%20that%20the%20Log%20Monitor%20tool%20should%20monitor.%20Note%20that%20there%20can%20be%20more%20than%20one%20directory%2C%20though%20additionally%20directories%20should%20be%20added%20as%20an%20additional%20json%20source%20object%20with%20type%3DFile.%3C%2FFONT%3E%3C%2FLI%3E%0A%3CLI%3E%3CFONT%20size%3D%224%22%3Efilter.%20This%20string%20field%20indicates%20what%20files%20under%20the%20directory%20the%20Log%20Monitor%20should%20monitor.%20The%20string%20is%20parsed%20for%20regex%20format.%3C%2FFONT%3E%3C%2FLI%3E%0A%3CLI%3E%3CFONT%20size%3D%224%22%3EincludeSubdirectories.%20This%20Boolean%20field%20indicates%20whether%20the%20Log%20Monitor%20should%20recurse%20the%20subdirectories%20of%20the%20indicated%20directory%20(true)%20or%20remain%20in%20the%20indicated%20directory%20(false).%3C%2FFONT%3E%3C%2FLI%3E%0A%3C%2FUL%3E%0A%3CLI%3E%3CFONT%20size%3D%224%22%3E%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fwindows%2Fwin32%2Fetw%2Fabout-event-tracing%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noopener%20noreferrer%20noopener%20noreferrer%22%3EETW%20(Event%20Tracing%20for%20Windows).%3C%2FA%3E%20ETW%20is%20an%20efficient%20kernel-level%20tracing%20facility%20that%20lets%20you%20log%20system%20or%20application%20defined%20events%20to%20a%20log%20file%20or%20access%20them%20real-time.%20Applications%20often%20instrument%20providers%20that%20are%20enabled%20to%20generate%20events%20as%20relevant%20to%20the%20application.%20The%20Log%20Monitor%20tool%20can%20be%20configured%20to%20watch%20certain%20relevant%20providers.%20The%20configuration%20file%20supports%20the%20following%20fields%3A%3C%2FFONT%3E%3C%2FLI%3E%0A%3CUL%3E%0A%3CLI%3E%3CFONT%20size%3D%224%22%3EeventFormatMultiLine.%20The%20behavior%20is%20the%20same%20as%20described%20above.%20This%20does%20not%20have%20to%20match%20the%20Boolean%20chosen%20for%20the%20Event%20Log.%3C%2FFONT%3E%3C%2FLI%3E%0A%3CLI%3E%3CFONT%20size%3D%224%22%3EProviders.%20This%20field%20is%20a%20list%20of%20providers%20that%20indicates%20what%20providers%20the%20Log%20Monitor%20tool%20should%20monitor.%20The%20following%20fields%20are%20supported%20for%20each%20provider%3A%3C%2FFONT%3E%3C%2FLI%3E%0A%3CUL%3E%0A%3CLI%3E%3CFONT%20size%3D%224%22%3EproviderName.%3C%2FFONT%3E%3C%2FLI%3E%0A%3CLI%3E%3CFONT%20size%3D%224%22%3EProviderGuid.%20For%20Server%20Core%20or%20Windows%20base%20images%2C%20note%20that%20either%20providerName%20or%20ProviderGuid%20can%20be%20provided.%20For%20Nanoserver%20ProviderGuid%20is%20required%20as%20resolving%20provider%20name%20to%20GUID%20is%20a%20known%20issue.%3C%2FFONT%3E%3C%2FLI%3E%0A%3CLI%3E%3CFONT%20size%3D%224%22%3Elevel%3A%20a%201-byte%20integer%20that%20enables%20filtering%20based%20on%20the%20severity%20or%20verbosity%20of%20events%3C%2FFONT%3E%3C%2FLI%3E%0A%3CLI%3E%3CFONT%20size%3D%224%22%3Ekeywords%3A%20This%20string%20field%20is%20a%20bitmask%20that%20specifies%20what%20events%20to%20collect.%20Only%20events%20with%20keywords%20matching%20the%20bitmask%20are%20collected%20This%20is%20an%20optional%20parameter.%20Default%20is%200%20and%20all%20the%20events%20will%20be%20collected.%3C%2FFONT%3E%3C%2FLI%3E%0A%3C%2FUL%3E%0A%3C%2FUL%3E%0A%3C%2FUL%3E%0A%3CP%3E%3CFONT%20size%3D%224%22%3ENote%20that%20which%20events%2C%20files%2C%20and%20ETW%20providers%20an%20application%20logs%20to%20is%20defined%20by%20the%20application.%20There%20are%20some%20standard%20patterns%20for%20some%20common%20applications%20such%20as%20IIS.%20Some%20sample%20config%20files%20for%20these%20popular%20scenarios%20are%20included%20in%20the%20%3CA%20href%3D%22https%3A%2F%2Fgithub.com%2Fmicrosoft%2Fwindows-container-tools%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noopener%20noreferrer%20noopener%20noreferrer%22%3EGithub%20repo%3C%2FA%3E.%20If%20information%20about%20which%20events%2C%20files%2C%20and%20ETW%20providers%20a%20particular%20application%20logs%20to%20is%20not%20readily%20available%2C%20wevutil%20or%20Event%20Viewer%20can%20help.%3C%2FFONT%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CU%3E%3CSTRONG%3E%3CFONT%20size%3D%224%22%3EWhat%20is%20next%3F%3C%2FFONT%3E%3C%2FSTRONG%3E%3C%2FU%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CFONT%20size%3D%224%22%3EWhile%20we%20are%20excited%20to%20bring%20this%20functionality%20to%20our%20users%2C%20this%20is%20just%20the%20beginning%20of%20our%20journey.%20By%20open%20sourcing%20this%20tool%2C%20we%20hope%20to%20continuously%20gather%20feedback%20and%20improve%20the%20tool%20to%20meet%20customer%20needs.%20Some%20areas%20we%20have%20already%20identified%20and%20are%20investigating%20for%20future%20releases%3A%3C%2FFONT%3E%3C%2FP%3E%0A%3CUL%3E%0A%3CLI%3E%3CFONT%20size%3D%224%22%3ERotating%20log%20support%3C%2FFONT%3E%3C%2FLI%3E%0A%3CLI%3E%3CFONT%20size%3D%224%22%3EEnvironment%20variable%20configuration%20support%3C%2FFONT%3E%3C%2FLI%3E%0A%3CLI%3E%3CFONT%20size%3D%224%22%3EConfigMap%20support%3C%2FFONT%3E%3C%2FLI%3E%0A%3CLI%3E%3CFONT%20size%3D%224%22%3EIntegrations%20with%20log%20aggregation%20services%20at%20scale%3C%2FFONT%3E%3C%2FLI%3E%0A%3CLI%3E%3CFONT%20size%3D%224%22%3EConfiguration%20updates%20during%20container%20runtime%3C%2FFONT%3E%3C%2FLI%3E%0A%3CLI%3E%3CFONT%20size%3D%224%22%3EPerformance%3C%2FFONT%3E%3C%2FLI%3E%0A%3CLI%3E%3CFONT%20size%3D%224%22%3ESidecar%20usage%20patterns%3C%2FFONT%3E%3C%2FLI%3E%0A%3CLI%3E%3CFONT%20size%3D%224%22%3ELog%20driver%20support%3C%2FFONT%3E%3C%2FLI%3E%0A%3C%2FUL%3E%3C%2FLINGO-BODY%3E%3CLINGO-TEASER%20id%3D%22lingo-teaser-973947%22%20slang%3D%22en-US%22%3E%3CP%3ETL%3BDR%3A%20Windows%20Containers%20Log%20Monitor%20is%20opensource%20released%20%3CA%20href%3D%22https%3A%2F%2Fgithub.com%2Fmicrosoft%2Fwindows-container-tools%22%20rel%3D%22noopener%20noreferrer%20noopener%20noreferrer%22%20target%3D%22_blank%22%3Eon%20Github.%3C%2FA%3E%3C%2FP%3E%3C%2FLINGO-TEASER%3E
Microsoft

TL;DR: Windows Containers Log Monitor is opensource released on Github.

 

In this blog post we announced our efforts to improve the tooling experience for containers. The first step in this journey was with a log tool concept we demoed during our container session at //build. This demo was met with clear excitement from attendees and interest from the community. After gathering customer feedback, we set out to bring this tool to production quality and make it open source available for our Windows Containers users.

 

Today, we are happy to announce the opensource release of the Windows Container Log Monitor, now available on Github! This blog offers a deep dive into the architecture and usage of the tool.

 

To recap, unlike Linux applications that log to STDOUT, Windows applications log to Windows log locations such as ETW, Event Log, and custom log files. Since many container ecosystem logging solutions are built to pull from the STDOUT pipeline as standard with Linux, Windows containers app logs historically have not been accessible via these solutions. The Log Monitor bridges this gap between Windows log locations and STDOUT, as depicted in the diagram below. The scope of the Log Monitor tool is to bridge Windows application logs to the STDOUT pipeline.

 

ignitelogblog.png

 

The Log Monitor tool consists of two primary elements: LogMonitor.exe and LogMonitorConfig.json. Like the //build demo POC, the Log Monitor is authored with an observer, publisher-subscriber design pattern; however, instead of subscribing to hardcoded log source providers as in the original concept, the Log Monitor is configured to subscribe to a  set of sources defined by the user in the Log Monitor Config file.

The log sources supported by the Log Monitor tool include:

  • ETW
  • Event Logs
  • Log files

Note that these sources differ from the original concept, which collected Perf Counters and did not collect Event Logs. From feedback we concluded that Perf Counters, while useful, fall closer to system metrics than application logs, and were thus out of scope for this release. Additionally, the Log Monitor tool does not monitor the lifecycle of services within the container as in the original concept, but instead provides a nesting pattern so users can define their own service monitor or desired application.

 

The log tool is supported for Windows, Server Core, and Nano images.

 

Usage

 

A key point of feedback we received at //build and in the post-build survey was that the entry point-only solution restricts users from using their own app as the entry point process. We mitigate this with several options on usage:

  1. The Log Monitor tool can be used as the SHELL or the ENTRYPOINT
  2. As either the SHELL or ENTRYPOINT, another application can be indicated as a parameter to the Log Monitor tool as a nested process. The Log Monitor tool will spin up that process and monitor its STDOUT so that it also continues to show up in the container STDOUT. This mitigates the foreground/background process issue that existed in the original concept.

An example dockerfile for the SHELL usage pattern (with nesting):

 

 

 

FROM mcr.mt.com/windows/servercore:1903
#LogMonitor directory contains LogMonitor.exe and LogMonitorConfig.json file
COPY LogMonitor/ C:/LogMonitor
WORKDIR /LogMonitor
SHELL ["C:\\LogMonitor\\LogMonitor.exe", "cmd", "/S", "/C"]
CMD c:\windows\system32\ping.exe -n 20 localhost

 

 

 

An example dockerfile for the ENTRYPOINT usage pattern (with nesting):

 

 

 

FROM mcr.microsoft.com/windows/servercore:1903
#LogMonitor directory contains LogMonitor.exe and LogMonitorConfig.json file
COPY LogMonitor/ C:/LogMonitor    
WORKDIR /LogMonitor
ENTRYPOINT C:\LogMonitor\LogMonitor.exe  c:\windows\system32\ping.exe -n 20 localhost

 

 

 

Note that in the SHELL usage pattern the CMD/ENTRYPOINT instruction should be specified in the SHELL form and not exec form. When exec form of the CMD/ENTRYPOINT instruction is used, SHELL is not launched, and the Log Monitor tool will not be launched inside the container.

 

Additionally, if you are building from an image that pre-defines an entrypoint (i.e. an IIS image that pre-defines IIS.ServiceMonitor as the entry point), you must redefine the entrypoint in your dockerfile, either as the Log Monitor if you are using the ENTRYPOINT pattern, or as the pre-defined entrypoint. If you do not redefine the ENTRYPOINT of your dockerfile and are using the SHELL usage pattern, the Log Monitor tool will not work. This is because the SHELL is tied to the entrypoint definition.

 

Both example usages wrap the ping.exe application. Other applications such as IIS.ServiceMonitor can be nested with Log Monitor in a similar fashion:

 

 

 

COPY LogMonitor.exe LogMonitorConfig.json C:\LogMonitor\
WORKDIR /LogMonitor
SHELL ["C:\\LogMonitor\\LogMonitor.exe", "powershell.exe"]
 
# Start IIS Remote Management and monitor IIS
ENTRYPOINT      Start-Service WMSVC; `
                    C:\ServiceMonitor.exe w3svc;

 

 

 

Configuration

 

A sample Log Monitor Config file would be structured as follows:

 

 

 

{
  "LogConfig": {
    "sources": [
      {
        "type": "EventLog",
        "startAtOldestRecord": true,
        "eventFormatMultiLine": false,
        "channels": [
          {
            "name": "system",
            "level": "Error"
          }
        ]
      },
      {
        "type": "File",
        "directory": "c:\\inetpub\\logs",
        "filter": "*.log",
        "includeSubdirectories": true
      },
      {
        "type": "ETW",
        "providers": [
          {
            "providerName": "IIS: WWW Server",
            "ProviderGuid": "3A2A4E84-4C21-4981-AE10-3FDA0D9B0F83",
            "level": "Information"
          },
          {
            "providerName": "Microsoft-Windows-IIS-Logging",
            "ProviderGuid ": "7E8AD27F-B271-4EA2-A783-A47BDE29143B",
            "level": "Information" ,
            "keywords": "0xFF"
          }
        ]
      }
    ]
  }
}

 

 

 

In the config file there are the three log types you can configure the Log Monitor tool to pull from:

  • Event Logs. The event log provides a standard, centralized way for apps and the OS to record important software and hardware events. Each event is in a structured data format, which makes it easy to parse for event log view panes (i.e. Event Viewer) or examine with a programmatic interface. The configuration file supports the following fields:
    • startAtOldestRecord. This Boolean field indicates whether the Log Monitor tool should output event logs from the start of the container boot (true) or from the start of the Log Monitor tool itself (false).
    • eventFormatMultiLine. This Boolean field indicates whether the Log Monitor should format the logs to STDOUT as multi-line or single line. If set true, the tool does not format the event messages to a single line (and thus event messages can span multiple lines). If set to false, the tool formats the event log messages to a single line and removes new line characters. Many container tools that build upon docker logs and the STDOUT pipe assume each log entry is on a single line as Linux event messages are typically single line.
    • channels.  A channel is a sync that collects events. The wevutil tool can be used to enumerate channels via the command “wevutil el.”
      • Name. Name of the event channel
      • Level. This string field specifies the verboseness of the events collected. Possible values in ascending order of verbosity are Critical, Error, Warning, Information, and Verbose. Verbose encompasses Critical, Error, and Warning, and Information.
  • Custom Log File. Many apps log to custom app log files. Some services such as the IIS service also log to files in well-known locations. The Log Monitor tool can be configured to parse through custom log files and bridge these entries to STDOUT. The configuration file supports the following fields:
    • directory. This string field indicates the directory that the Log Monitor tool should monitor. Note that there can be more than one directory, though additionally directories should be added as an additional json source object with type=File.
    • filter. This string field indicates what files under the directory the Log Monitor should monitor. The string is parsed for regex format.
    • includeSubdirectories. This Boolean field indicates whether the Log Monitor should recurse the subdirectories of the indicated directory (true) or remain in the indicated directory (false).
  • ETW (Event Tracing for Windows). ETW is an efficient kernel-level tracing facility that lets you log system or application defined events to a log file or access them real-time. Applications often instrument providers that are enabled to generate events as relevant to the application. The Log Monitor tool can be configured to watch certain relevant providers. The configuration file supports the following fields:
    • eventFormatMultiLine. The behavior is the same as described above. This does not have to match the Boolean chosen for the Event Log.
    • Providers. This field is a list of providers that indicates what providers the Log Monitor tool should monitor. The following fields are supported for each provider:
      • providerName.
      • ProviderGuid. For Server Core or Windows base images, note that either providerName or ProviderGuid can be provided. For Nanoserver ProviderGuid is required as resolving provider name to GUID is a known issue.
      • level: a 1-byte integer that enables filtering based on the severity or verbosity of events
      • keywords: This string field is a bitmask that specifies what events to collect. Only events with keywords matching the bitmask are collected This is an optional parameter. Default is 0 and all the events will be collected.

Note that which events, files, and ETW providers an application logs to is defined by the application. There are some standard patterns for some common applications such as IIS. Some sample config files for these popular scenarios are included in the Github repo. If information about which events, files, and ETW providers a particular application logs to is not readily available, wevutil or Event Viewer can help.

 

What is next?

 

While we are excited to bring this functionality to our users, this is just the beginning of our journey. By open sourcing this tool, we hope to continuously gather feedback and improve the tool to meet customer needs. Some areas we have already identified and are investigating for future releases:

  • Rotating log support
  • Environment variable configuration support
  • ConfigMap support
  • Integrations with log aggregation services at scale
  • Configuration updates during container runtime
  • Performance
  • Sidecar usage patterns
  • Log driver support