Comments (3)
Hi @MCrank can you provide an example of the code you're having issue with?
from logging.
Sure thing. Here is my Configuration:
Set-LoggingDefaultLevel -Level $LogLevel
Add-LoggingLevel -Level 50 -LevelName SLACK
$ScriptName = [System.IO.Path]::GetFileNameWithoutExtension($MyInvocation.MyCommand.Name)
Add-LoggingTarget -Name File -Configuration @{
Path = "$($PSScriptRoot)\Logs\$($env:COMPUTERNAME)_$($ScriptName)_%{+%Y%m%d}.log"
}
Add-LoggingTarget -Name Slack -Configuration @{
WebHook = "$env:NightlySlackURL";
Level = 'SLACK'
}
So when I needed to send something critical that needs my attention to slack I would call it like this:
Write-Log -Level 'SLACK' -Message "Critical message goes here"
This would write the message to the Log file and send the message to slack as well. With the latest version my Write-Log statements would all get fired to the log and slack even when not targeting the SLACK
logging level.
Otherwise I would just call Write-Log and set -Level to one of the default DEBUG, INFO, ERROR, etc to just output to the log file.
Here are the lines that used to handle this in Logging.psm1
I think.
https://github.com/EsOsO/Logging/blob/e62cd0b185588972bce7731c05aa9359effe456d/Logging/Logging.psm1#L102-L104
Oh and the version that I am using that works in this way is 2.7.2
from logging.
Hi @MCrank, since the introductions of defaults target configurations, the default target level doesn't honor the Set-LoggingDefaultLevel
(I'll open an issue about that).
Right now you have to explicitly set the target level in the Add-LoggingTarget
otherwise it will be set to NOTSET.
from logging.
Related Issues (20)
- AzureLogAnalytics target generates an error when no Body provided
- Create dev builds
- Build against Linux, MacOS, Windows / Windows Powershell, Powershell
- Are target names case sensitive? HOT 2
- Add variable hostname to $logMessage HOT 6
- Support for multiple Teams channels HOT 2
- File Target is converting $Log.body to json permanently HOT 1
- Not support Chinese? or any other Unicode language?
- Import-Module raises errors if in a script strict mode
- MS Teams Target: Proxy Support HOT 1
- Get-LoggingMessageCount.ps1 missing
- Wait-Logging Hanging Scheduled Task HOT 3
- Logging target mail: send Bulk Log
- Add support for PS transcript (Start-Transcript)
- Question: Support for colors in the format string
- Reset-LoggingTarget or -Scope param? HOT 6
- File Target with Relative Path HOT 4
- Most targets ignore -ExceptionInfo HOT 1
- SEQ: structured logging not implemented HOT 4
- NotifyBeginApplication/NotifyEndApplication calls not needed?
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from logging.