You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardexpand all lines: error-handler/index.md
+18-1
Original file line number
Diff line number
Diff line change
@@ -67,6 +67,7 @@ Fano Framework comes with several `IErrorHandler` implementation.
67
67
-`TNullErrorHandler`, error handler that output nothing except HTTP error.
68
68
-`THtmlAjaxErrorHandler`, composite error handler that output basic HTML error or JSON based on whether request is AJAX or not.
69
69
-`TLogErrorHandler`, error handler that log error information instead of output it to client.
70
+
-`TLoggerErrorHandler`, error handler that similar to `TLogErrorHandler` except it can determine what log level to be log. For example it can log critical type log only.
70
71
-`TTemplateErrorHandler`, error handler that output error using HTML template. This class is provided to enable developer to display nicely formatted error page. For production setup, this is mostly what you use.
71
72
-`TCompositeErrorHandler` error handler that is composed from two other error handler. This is provided so we combine, for example, log error to file and also displaying nicely formatted output to client. To combine three or more error handlers, you need to daisy-chain them.
72
73
-`TGroupErrorHandler` error handler that is composed from one or more error handlers. This is similar to composite error handler above, except, it is more flexible as you can compose arbitrary number of error handlers.
@@ -159,7 +160,23 @@ begin
159
160
end;
160
161
```
161
162
162
-
You need to make sure that `/path/to/log/file` is writeable. Read [Using Logger documentation](/utilities/using-loggers) for more information on how to use logger utility.
163
+
You need to make sure that `/path/to/log/file` is writeable.
164
+
165
+
Or if you want to log emergency and critical message only, use `TLoggerErrorHandler` instead.
166
+
```
167
+
function TAppServiceProvider.buildErrorHandler(
168
+
const ctnr : IDependencyContainer;
169
+
const config : IAppConfiguration
170
+
) : IErrorHandler;
171
+
begin
172
+
result := TLoggerErrorHandler.create(
173
+
TFileLogger.create('/path/to/log/file'),
174
+
[ logEmergency, logCritical ]
175
+
);
176
+
end;
177
+
```
178
+
179
+
Read [Using Logger documentation](/utilities/using-loggers) for more information on how to use logger utility.
163
180
164
181
## Log error to file and display error from template
0 commit comments