Exercise: Building a Log Filtering Utility
Create a Node.js utility to filter specific lines from large log files and save the results.
We'll cover the following...
We'll cover the following...
Task
Create a Node.js script that reads a large log file and filters out the lines containing the word "ERROR", and writes the remaining lines to a new file.
Instructions
Use
fs.createReadStreamto read the filelogs.txtin chunks.Create a transform stream to filter out lines containing the word "ERROR".
Use
fs.createWriteStreamto write the filtered logs tofiltered-logs.txt.Pipe the streams together for seamless processing.
Sample input
The following are the contents of sample input file logs.txt: