Comments (7)
Disregard my previous comment, cannot reproduce.
I removed the random start-sleep and saw the errors displayed...
[2019-05-22 13:19:35-04] [ERROR ] Message n. 97
Out-File : Cannot find drive. A drive with the name 'C' does not exist.
At /Users/jason.chester/.local/share/powershell/Modules/Logging/4.1.1/targets/File.ps1:32 char:17
+ $Text | Out-File @Params
+ ~~~~~~~~~~~~~~~~
+ CategoryInfo : ObjectNotFound: (C:String) [Out-File], DriveNotFoundException
+ FullyQualifiedErrorId : DriveNotFound,Microsoft.PowerShell.Commands.OutFileCommand
from logging.
since $PSEdition isn't available before PS 5.1 a better check might be to test the property itself...
if($initialState.ApartmentState) { $true }
from logging.
@EsOsO PowerShell/PowerShell#6908. The created InitialSessionState should be MTA by default.
from logging.
Ok, we should drop the ApartmentState assignment ad use deafult
from logging.
Okay, after some testing it seems like this is not true for all PowerShell versions...
I would include the following code snippet.
$initialState = [InitialSessionState]::CreateDefault()
if (Get-Member -InputObject $initialState -Name "ApartmentState" -MemberType Property) {
$initialState.ApartmentState = [System.Threading.ApartmentState]::MTA
}
from logging.
@jasonchester There is a new version up for download, implementing the wanted check. Could you test the functionality for powershell core with the updated version?
from logging.
@tosoikea this works on powershell core now...
one strange thing I noticed when running the sample code
Set-LoggingDefaultLevel -Level 'WARNING'
Add-LoggingTarget -Name Console
Add-LoggingTarget -Name File -Configuration @{Path = 'C:\Temp\example_%{+%Y%m%d}.log'}
$Level = 'DEBUG', 'INFO', 'WARNING', 'ERROR'
foreach ($i in 1..100) {
Write-Log -Level ($Level | Get-Random) -Message 'Message n. {0}' -Arguments $i
Start-Sleep -Milliseconds (Get-Random -Min 100 -Max 1000)
}
Wait-Logging
is that the system hung... i identified the issue as the path set here:
Add-LoggingTarget -Name File -Configuration @{Path = 'C:\Temp\example_%{+%Y%m%d}.log'}
was not valid on my mac but instead of displaying a meaningful error message, logging appears to hang. One suggestion i would have would be to validate creating a file when adding a target or at least trapping any errors when writing to a target.
Otherwise everything looked great, thanks for the help.
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.