WEBVTT

00:04.910 --> 00:10.920
Engine X provides us two log types error logs and access logs a log.

00:10.970 --> 00:17.720
As the name suggests for anything that failed or didn't happen as expected and access logs to log all

00:17.720 --> 00:19.800
requests to the server.

00:19.970 --> 00:26.060
Logging is an extremely important aspect of not only in generics but web servers in general as logs

00:26.060 --> 00:30.330
allow us to track down errors or even identify malicious users.

00:30.380 --> 00:32.570
Logging has also enabled by default.

00:32.600 --> 00:39.200
So for that reason most of the time leaving the lock configuration as is will be fine but understanding

00:39.200 --> 00:45.830
how to change them is definitely important and disabling logs for certain conditions or creating resource

00:45.830 --> 00:51.570
specific logs can both help lower resource usage and improve the log file structure.

00:51.620 --> 00:56.990
In our case we said the path to the log files when we configured in generics in the installation section

00:56.990 --> 01:02.700
of the course which was slash var slash log slash engine X..

01:03.570 --> 01:06.260
And if we list the contents of that directory.

01:07.040 --> 01:14.000
We see those two log files error log and accessed log with both files already containing several entries

01:14.030 --> 01:17.970
from throughout this course as we can see from the file sizes.

01:18.410 --> 01:20.960
I'll change into that logs directory.

01:21.760 --> 01:27.990
And clear both of these log files so we can start from scratch just echo an empty string to access dot

01:27.990 --> 01:28.880
log.

01:29.020 --> 01:31.090
And same for error dot log.

01:31.120 --> 01:31.680
Done.

01:33.460 --> 01:40.730
Then to see a default access log entry head over to the browser and request slash a thumb dot PRNG.

01:41.650 --> 01:42.580
That loads.

01:42.610 --> 01:44.470
So check the access log.

01:45.520 --> 01:48.840
And there we have it for thumb dot PRNG.

01:49.150 --> 01:55.810
Now a very common misconception is that forro fours get logged in the error log which most of the time

01:55.870 --> 01:57.550
is not the case.

01:57.550 --> 02:04.290
First let's reset this configuration back to serving the demo site without any rewrites save that.

02:06.750 --> 02:07.840
Reload.

02:08.700 --> 02:16.590
And again in the browser I'll request a u r l that does not exist say slash missing which gives us that

02:16.590 --> 02:18.970
standard engine X for a 4.

02:19.080 --> 02:20.410
Check the access log.

02:21.190 --> 02:22.330
And there we have it.

02:22.420 --> 02:25.310
That request with a status of four of four.

02:25.330 --> 02:32.710
Now I say not always as a properly handled foro for won't produce an error blog entry but in our case

02:33.070 --> 02:36.940
log that out engine X could not match a file to the request.

02:36.940 --> 02:37.630
You are right.

02:37.750 --> 02:39.470
And resulted in an error.

02:39.520 --> 02:44.920
Just something to keep in mind for a form is a perfectly valid response and by no means an error in

02:44.920 --> 02:52.490
itself to create a typical entry in the error log then will have to cause engine X to actually malfunction.

02:52.510 --> 02:58.990
For example I'll add a second argument to the root directive which only expects a single argument save

02:58.990 --> 03:02.430
this attempt to reload the configuration.

03:03.840 --> 03:11.130
Which has of course silently failed but in there a log we have that error entry invalid number of arguments

03:11.190 --> 03:16.360
in root directive with a reference to the line in the configuration file.

03:16.440 --> 03:22.770
We can also create custom log files or disable logging all together for a given context by means of

03:22.770 --> 03:27.350
the access underscore log or error underscore log directives.

03:27.390 --> 03:32.590
For example let's say we want to add an exit log for all requests to slash secure.

03:32.850 --> 03:38.810
I'll create a location context for that you are by returning a simple string.

03:39.150 --> 03:41.470
Welcome to secure area.

03:41.760 --> 03:50.400
And in here enable an access log by saying access underscore log with a path to that log file var log

03:50.490 --> 03:58.470
slash engine X. secure dot access dot log keeping it in that engine log directory save.

03:59.710 --> 04:07.390
Reload the configuration and immediately if we list the contents of our log in generics that file has

04:07.390 --> 04:10.900
already been created ready to log requests.

04:11.780 --> 04:13.980
Navigate to slash secure.

04:15.110 --> 04:16.420
We get the message.

04:16.430 --> 04:18.230
So check the access log.

04:19.100 --> 04:20.450
And there it is.

04:20.480 --> 04:26.660
Whilst no longer existing in the global access log it is possible to log this to both However by simply

04:26.660 --> 04:29.520
adding another access log with the global path.

04:29.690 --> 04:35.330
In which case we'll get that log entry and both log directives being one of the few directives you can

04:35.330 --> 04:41.180
use multiple times like this but will cover directive types in more detail in the next lesson.

04:41.180 --> 04:47.360
Another common use of the log directive is to disable logging for certain requests and in doing so reducing

04:47.360 --> 04:53.660
server load and keeping log files smaller particularly useful for sites receiving very high traffic

04:54.320 --> 05:00.730
to disable logging for a given context then it's as simple as saying access underscore log off.

05:01.460 --> 05:08.060
Generally I'd say disable the majority of access logs and leave error logging in place but this will

05:08.060 --> 05:14.210
depend on individual server requirements for more advanced logging configurations we can also specify

05:14.210 --> 05:20.620
the access log format enabled Jesus being of the log file or set the log level for error logs.

05:20.780 --> 05:25.000
But again that's typically for larger more advanced configurations.

05:25.070 --> 05:29.150
I've linked to a very good engine XT dot.com article in the LIS and resources.

05:29.240 --> 05:32.930
Should you be interested in these advanced options in the next lesson.

05:32.930 --> 05:37.770
We'll take a look at those different DirecTV types and the basics of inheritance.
