Engine X provides us two log types error logs and access logs a log.
As the name suggests for anything that failed or didn't happen as expected and access logs to log all
requests to the server.
Logging is an extremely important aspect of not only in generics but web servers in general as logs
allow us to track down errors or even identify malicious users.
Logging has also enabled by default.
So for that reason most of the time leaving the lock configuration as is will be fine but understanding
how to change them is definitely important and disabling logs for certain conditions or creating resource
specific logs can both help lower resource usage and improve the log file structure.
In our case we said the path to the log files when we configured in generics in the installation section
of the course which was slash var slash log slash engine X..
And if we list the contents of that directory.
We see those two log files error log and accessed log with both files already containing several entries
from throughout this course as we can see from the file sizes.
I'll change into that logs directory.
And clear both of these log files so we can start from scratch just echo an empty string to access dot
log.
And same for error dot log.
Done.
Then to see a default access log entry head over to the browser and request slash a thumb dot PRNG.
That loads.
So check the access log.
And there we have it for thumb dot PRNG.
Now a very common misconception is that forro fours get logged in the error log which most of the time
is not the case.
First let's reset this configuration back to serving the demo site without any rewrites save that.
Reload.
And again in the browser I'll request a u r l that does not exist say slash missing which gives us that
standard engine X for a 4.
Check the access log.
And there we have it.
That request with a status of four of four.
Now I say not always as a properly handled foro for won't produce an error blog entry but in our case
log that out engine X could not match a file to the request.
You are right.
And resulted in an error.
Just something to keep in mind for a form is a perfectly valid response and by no means an error in
itself to create a typical entry in the error log then will have to cause engine X to actually malfunction.
For example I'll add a second argument to the root directive which only expects a single argument save
this attempt to reload the configuration.
Which has of course silently failed but in there a log we have that error entry invalid number of arguments
in root directive with a reference to the line in the configuration file.
We can also create custom log files or disable logging all together for a given context by means of
the access underscore log or error underscore log directives.
For example let's say we want to add an exit log for all requests to slash secure.
I'll create a location context for that you are by returning a simple string.
Welcome to secure area.
And in here enable an access log by saying access underscore log with a path to that log file var log
slash engine X. secure dot access dot log keeping it in that engine log directory save.
Reload the configuration and immediately if we list the contents of our log in generics that file has
already been created ready to log requests.
Navigate to slash secure.
We get the message.
So check the access log.
And there it is.
Whilst no longer existing in the global access log it is possible to log this to both However by simply
adding another access log with the global path.
In which case we'll get that log entry and both log directives being one of the few directives you can
use multiple times like this but will cover directive types in more detail in the next lesson.
Another common use of the log directive is to disable logging for certain requests and in doing so reducing
server load and keeping log files smaller particularly useful for sites receiving very high traffic
to disable logging for a given context then it's as simple as saying access underscore log off.
Generally I'd say disable the majority of access logs and leave error logging in place but this will
depend on individual server requirements for more advanced logging configurations we can also specify
the access log format enabled Jesus being of the log file or set the log level for error logs.
But again that's typically for larger more advanced configurations.
I've linked to a very good engine XT dot.com article in the LIS and resources.
Should you be interested in these advanced options in the next lesson.
We'll take a look at those different DirecTV types and the basics of inheritance.