1 00:00:04,910 --> 00:00:10,920 Engine X provides us two log types error logs and access logs a log. 2 00:00:10,970 --> 00:00:17,720 As the name suggests for anything that failed or didn't happen as expected and access logs to log all 3 00:00:17,720 --> 00:00:19,800 requests to the server. 4 00:00:19,970 --> 00:00:26,060 Logging is an extremely important aspect of not only in generics but web servers in general as logs 5 00:00:26,060 --> 00:00:30,330 allow us to track down errors or even identify malicious users. 6 00:00:30,380 --> 00:00:32,570 Logging has also enabled by default. 7 00:00:32,600 --> 00:00:39,200 So for that reason most of the time leaving the lock configuration as is will be fine but understanding 8 00:00:39,200 --> 00:00:45,830 how to change them is definitely important and disabling logs for certain conditions or creating resource 9 00:00:45,830 --> 00:00:51,570 specific logs can both help lower resource usage and improve the log file structure. 10 00:00:51,620 --> 00:00:56,990 In our case we said the path to the log files when we configured in generics in the installation section 11 00:00:56,990 --> 00:01:02,700 of the course which was slash var slash log slash engine X.. 12 00:01:03,570 --> 00:01:06,260 And if we list the contents of that directory. 13 00:01:07,040 --> 00:01:14,000 We see those two log files error log and accessed log with both files already containing several entries 14 00:01:14,030 --> 00:01:17,970 from throughout this course as we can see from the file sizes. 15 00:01:18,410 --> 00:01:20,960 I'll change into that logs directory. 16 00:01:21,760 --> 00:01:27,990 And clear both of these log files so we can start from scratch just echo an empty string to access dot 17 00:01:27,990 --> 00:01:28,880 log. 18 00:01:29,020 --> 00:01:31,090 And same for error dot log. 19 00:01:31,120 --> 00:01:31,680 Done. 20 00:01:33,460 --> 00:01:40,730 Then to see a default access log entry head over to the browser and request slash a thumb dot PRNG. 21 00:01:41,650 --> 00:01:42,580 That loads. 22 00:01:42,610 --> 00:01:44,470 So check the access log. 23 00:01:45,520 --> 00:01:48,840 And there we have it for thumb dot PRNG. 24 00:01:49,150 --> 00:01:55,810 Now a very common misconception is that forro fours get logged in the error log which most of the time 25 00:01:55,870 --> 00:01:57,550 is not the case. 26 00:01:57,550 --> 00:02:04,290 First let's reset this configuration back to serving the demo site without any rewrites save that. 27 00:02:06,750 --> 00:02:07,840 Reload. 28 00:02:08,700 --> 00: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 29 00:02:16,590 --> 00:02:18,970 standard engine X for a 4. 30 00:02:19,080 --> 00:02:20,410 Check the access log. 31 00:02:21,190 --> 00:02:22,330 And there we have it. 32 00:02:22,420 --> 00:02:25,310 That request with a status of four of four. 33 00:02:25,330 --> 00: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 34 00:02:33,070 --> 00:02:36,940 log that out engine X could not match a file to the request. 35 00:02:36,940 --> 00:02:37,630 You are right. 36 00:02:37,750 --> 00:02:39,470 And resulted in an error. 37 00:02:39,520 --> 00:02:44,920 Just something to keep in mind for a form is a perfectly valid response and by no means an error in 38 00:02:44,920 --> 00:02:52,490 itself to create a typical entry in the error log then will have to cause engine X to actually malfunction. 39 00:02:52,510 --> 00:02:58,990 For example I'll add a second argument to the root directive which only expects a single argument save 40 00:02:58,990 --> 00:03:02,430 this attempt to reload the configuration. 41 00:03:03,840 --> 00:03:11,130 Which has of course silently failed but in there a log we have that error entry invalid number of arguments 42 00:03:11,190 --> 00:03:16,360 in root directive with a reference to the line in the configuration file. 43 00:03:16,440 --> 00:03:22,770 We can also create custom log files or disable logging all together for a given context by means of 44 00:03:22,770 --> 00:03:27,350 the access underscore log or error underscore log directives. 45 00:03:27,390 --> 00:03:32,590 For example let's say we want to add an exit log for all requests to slash secure. 46 00:03:32,850 --> 00:03:38,810 I'll create a location context for that you are by returning a simple string. 47 00:03:39,150 --> 00:03:41,470 Welcome to secure area. 48 00:03:41,760 --> 00:03:50,400 And in here enable an access log by saying access underscore log with a path to that log file var log 49 00:03:50,490 --> 00:03:58,470 slash engine X. secure dot access dot log keeping it in that engine log directory save. 50 00:03:59,710 --> 00:04:07,390 Reload the configuration and immediately if we list the contents of our log in generics that file has 51 00:04:07,390 --> 00:04:10,900 already been created ready to log requests. 52 00:04:11,780 --> 00:04:13,980 Navigate to slash secure. 53 00:04:15,110 --> 00:04:16,420 We get the message. 54 00:04:16,430 --> 00:04:18,230 So check the access log. 55 00:04:19,100 --> 00:04:20,450 And there it is. 56 00:04:20,480 --> 00:04:26,660 Whilst no longer existing in the global access log it is possible to log this to both However by simply 57 00:04:26,660 --> 00:04:29,520 adding another access log with the global path. 58 00:04:29,690 --> 00:04:35,330 In which case we'll get that log entry and both log directives being one of the few directives you can 59 00:04:35,330 --> 00:04:41,180 use multiple times like this but will cover directive types in more detail in the next lesson. 60 00:04:41,180 --> 00:04:47,360 Another common use of the log directive is to disable logging for certain requests and in doing so reducing 61 00:04:47,360 --> 00:04:53,660 server load and keeping log files smaller particularly useful for sites receiving very high traffic 62 00:04:54,320 --> 00:05:00,730 to disable logging for a given context then it's as simple as saying access underscore log off. 63 00:05:01,460 --> 00:05:08,060 Generally I'd say disable the majority of access logs and leave error logging in place but this will 64 00:05:08,060 --> 00:05:14,210 depend on individual server requirements for more advanced logging configurations we can also specify 65 00:05:14,210 --> 00:05:20,620 the access log format enabled Jesus being of the log file or set the log level for error logs. 66 00:05:20,780 --> 00:05:25,000 But again that's typically for larger more advanced configurations. 67 00:05:25,070 --> 00:05:29,150 I've linked to a very good engine XT dot.com article in the LIS and resources. 68 00:05:29,240 --> 00:05:32,930 Should you be interested in these advanced options in the next lesson. 69 00:05:32,930 --> 00:05:37,770 We'll take a look at those different DirecTV types and the basics of inheritance.