jpsider/RestPS

logging calling address

Closed this issue · 6 comments

I would like to see an option to log calls that hit the endpoint - similar to apache or iis - ie
[datetime] [fromIP/port] [toIp/port] [Url called] (or similar)

this can be obtained from the $script:request object:
RemoteEndpoint & LocalEndpoint & RawUrl properties.

#2 - Related ticket.
I agree, there needs to be quite a bit of logging added.

current format I have added - in the same folder the routes,json file is in:
[]: []:

eg:
2019-12-04T07:07:05 [::1]:56166 [::1]:8080 [GET] /monitor/endpoint/routes

#2 #36 - all related

Added PowerLumber - for Logging
This is the new console output:
image

This is the log file output
New file created.2020-03-23 18:09:42 INFO: Invoke-StartListener: Starting: http:// Listener on Port: 8081 2020-03-23 18:10:19 INFO: Start-RestPSListener: New Request - Method: GET URL: /endpoint/routes 2020-03-23 18:10:19 INFO: Start-RestPSListener: Processing RequestType: GET URL: /endpoint/routes Args: 2020-03-23 18:10:19 INFO: Invoke-RequestRouter: Importing RouteSet 2020-03-23 18:10:19 INFO: Invoke-RequestRouter: Executing Endpoint Script. 2020-03-23 18:10:19 INFO: Invoke-RequestRouter: Valid Response (200). 2020-03-23 18:10:19 INFO: Start-RestPSListener: Finished request. 2020-03-23 18:11:09 INFO: Start-RestPSListener: New Request - Method: GET URL: /endpoint/shutdown 2020-03-23 18:11:09 INFO: Invoke-StopListener: Stopping HTTP Listener on port: 8081 ...

ewww it word wrapped!

So those are the defaults for the new log options
-Logfile ($env:SystemDrive/RestPS/RestPS.log)
-LogLevel (INFO)

Probably need to tune the messages quite a bit, but it's a start!