Pode icon indicating copy to clipboard operation
Pode copied to clipboard

Enable-PodeErrorLogging cannot out-file

Open ericxin1982 opened this issue 2 years ago • 8 comments

Question

A clear and concise description of your question. #Error Log Enabled $method = New-PodeLoggingMethod -Custom -ScriptBlock { param($item) "$($item.Server) - $($item.Message)" | Out-File -FilePath 'D:\podebucket\pscode\bridge\logs\error.log' } $method | Enable-PodeErrorLogging -Raw

Hi @Badgerati

I encountered an issue, like enable-podeerrorlogging cannot output to a file, the normal way does not work, so I use custom way it does not work also.

Would you please advise how I should do, error log and redirect to a file. Requestlogging is fine, but I want errorlogging.

Thanks Eric Xin

ericxin1982 avatar Jul 03 '23 08:07 ericxin1982

Hi @ericxin1982

for me it just works as described in the tutorials

https://badgerati.github.io/Pode/Tutorials/Logging/Methods/File/ https://badgerati.github.io/Pode/Tutorials/Logging/Types/Errors/

New-PodeLoggingMethod -File -Name 'errors'  | Enable-PodeErrorLogging

Do you have any error message or does the file just not get created?

Do you have an example code of the non-working one?

SeriousMikeDE avatar Jul 03 '23 09:07 SeriousMikeDE

I do not have any error message, just the file not get created.

ericxin1982 avatar Jul 03 '23 11:07 ericxin1982

image image image

ericxin1982 avatar Jul 03 '23 12:07 ericxin1982

request no issue, I can see the file created. I am using the latest edtion.

ericxin1982 avatar Jul 03 '23 12:07 ericxin1982

Ooooh, @ericxin1982 are you expecting to see those Verbose lines in the terminal, but in a file instead? If so, then yes unfortunately those specific logs don't currently get redirected to file - they're generated by the underlying .NET library for Pode's socket listener.

It is something I've been thinking about how to redirect them to file actually, as I need to redirect logs from the .NET library up to PowerShell where the logging logic is - or, I move the inbuilt logging logic into the .NET library.

I'll try an have think about it for 2.9.0, but might be one for 2.10.0.

Badgerati avatar Jul 03 '23 21:07 Badgerati

Hi @Badgerati

I see. I do not have to see verbose directed to the file, I just make all log can be in one place, and I do not know what can cause informational, warning, error these higher error, would you please give me a way, I just want to make sure log file can be created, if verbose cannot, that is ok.

I am using -levels * that is fine, I just want to make sure the file can be created, and something can be there. That is fine. Actually I try to create a skeleton and share this good thing to let more person know, then I have to try each single chapter content.

Thanks Eric Xin

ericxin1982 avatar Jul 04 '23 00:07 ericxin1982

Hi @ericxin1982,

You can write custom error logs by using Write-PodeErrorLog: https://badgerati.github.io/Pode/Tutorials/Logging/Types/Errors/#writing-errors

Badgerati avatar Jul 07 '23 19:07 Badgerati

Hi @Badgerati

How to generate information error, debug error or warning error. I want to see the file log works as the tutorial said.

Thanks Eric Xin

ericxin1982 avatar Jul 08 '23 05:07 ericxin1982