# Logging
powerGate uses [Apache log4net]() as core logging library, and additionally [PostSharp Diagnostics]() for extended Debug logging.\
By default, all the logs are stored in a logfile located in *'C:\\Users\\\{USER}\\AppData\\Local\\coolOrange\\powerGate\\Logs\\powerGate.log'* and it contains only Warnings and Errors.\
Perhaps you can find backups of previous logfiles in this directory.
The log4net settings file is located in C:\\Program Files\\coolOrange\\Modules\\powerGate\\powerGate.log4net.\
Further information about log4Net Configurations can be found [here]().
## Log requests and responses
PowerGate has the opportunity to customize the format of the traced requests that are send to the server, and the received responses.
### Log Level
powerGate has a special logging level called **TRAFFIC**. In this level all **requests** and **responses** will be logged. The level is located in the order between **DEBUG** and **INFO**, but you can even adjust this by changing the value '30001' in these lines:
```{code-block} xml
:linenos:
```
In the following link you will find the default log levels associated with the numeric values they have at the bottom: [Level.cs]()
If you want to change the logging level for all appenders e.g. to "TRAFFIC", please visit the root logger and change the level in the lines:
```{code-block} xml
:linenos:
```
you can configure the required [logging level](). You could set the level to "DEBUG", than all the levels above Debug and also Debug will be logged.
:::{note}
When increasing the loglevel for the root logger, please make sure your favorite appenders minlevel is configured to allow logging messages with the specified level.
:::
### When to change the logging behavior?
When you have issues or when you want to get a more detailed knowledge about what powerGate is doing, you can increase the [logging level]().
:::{note}
When changing the loglevel to DEBUG [PostSharp Diagnostics]() will be enabled and will log all the function calls into the log files. This could cause performance issues
:::
Additionally you can change the logfile location or integrate the logging mechanism into your administrative environment by using build in EventLogMessages etc.
### TrafficPatternLayout
Each appender has its own layout that defines how the log-messages are formatted. By using the special Layout **powerGate.Erp.Client.Traffic.TrafficPatternLayout** you have the possibility to configure two new ConverstionPatterns: **RequestConversionPattern**, **ResponseConversionPattern**.
The **TrafficPatternLayout** has all the functionality of a simple [PatternLayout]() too. That means all logs that are not Requests or Responses can be configured by using the default **ConversionPattern** node.\
Therefore all the available conversion pattern names from [PatternLayout]() are available for the TrafficPatternLayout too.
### RequestConversionPattern
This pattern applies when a **request** gets logged and additionally you have access to following options:
```{code-block}
:linenos:
%Request{Protocol}
%Request{ProtocolVersion}
%Request{Method}
%Request{Url}
%Request{Headers}
%Request{Body}
```
For instance you are able to log something like this:
```{code-block} xml
:linenos:
```
This will result in logs like:\
*Called: GET on localhost:8080/pgs/ERP/MaterialService/Materials*
### ResponseConversionPattern
This pattern applies when a **response** gets logged and additionally you have access to following options:
```{code-block}
:linenos:
%Response{Protocol}
%Response{ProtocolVersion}
%Response{StatusCode}
%Response{Status}
%Response{Headers}
%Response{Body}
```
For instance you are able to log something like this:
```{code-block} xml
:linenos:
```
This will result in logs like:\
*Received: 200 OK*
## LogFile
You can see, that there are multiple logging-Appenders used. If you want to change the [logging level]() in the logfile, please visit following appender:
```{code-block} xml
:linenos:
```
In the lines
```{code-block} xml
:linenos:
```
you can configure the logginglevel. You could set the minimal filter level to "DEBUG", than all the levels between the range Debug and Fatal will be logged.
In the line
```{code-block} xml
:linenos:
```
you can configure the outputpath and name of the logfile.
## PowerShell IDE
PowerShell IDE's like PowerShell console (and PowerShell ISE) are configured to show the logging levels in a different color.
```{code-block} xml
:lineno-start: 38
```
These and many other options can be configured in the appender named **ColoredConsoleAppender**.