I tried to output the access log to the server using Node.js

Introduction

This article is written by a student studying JS etc. instead of a memo. Don't expect the content.

1. Build a virtual environment.

This time it will be done on Ubuntu, so start the virtual environment with iTerm2.

Where it started

  1. Virtual Box 2.Vagrant I use Ubuntu in a virtual environment that uses two software. cd ~/vagrant/ubuntu vagrant up vagrant ssh

Move to the directory where Ubuntu is installed. vagrant up is a command to start Ubuntu installed on a virtual PC, and vagrant ssh connects to SSH with the Vagrant virtual machine set.

2. Display the log on the created server

Describe the following contents in the arrow function of http.createServer.

console.info(


  '[' + new Date() + '] Requested by ' + reqest.connection.remoteAddress
);

This time, the request to the server is assigned to the variable called reqest. This time, the IP information to which the request was sent is output. I am using console.info, but info is categorized as follows.

Function name Contents output
info,log Information to leave from usual Standard output
warn,error warning Error standard output

3. Output an error to the created server

  console.error('[' + new Date() + '] Server Error', e);

The above on function is described after the arrow function.

4. Actually start the server

If you actually start the server and a console such as an error is displayed, it is successful.

Recommended Posts

I tried to output the access log to the server using Node.js
I tried to approximate the sin function using chainer
I tried to identify the language using CNN + Melspectogram
I tried to access Google Spread Sheets using Python
I tried to complement the knowledge graph using OpenKE
I tried to compress the image using machine learning
I tried to simulate ad optimization using the bandit algorithm.
I tried to approximate the sin function using chainer (re-challenge)
I tried to move the ball
I tried using the checkio API
I tried to estimate the interval.
I tried to get the index of the list using the enumerate function
I tried to digitize the stamp stamped on paper using OpenCV
I want to output to the console coolly
I tried using Azure Speech to Text.
I tried the asynchronous server of Django 3.0
I tried to summarize the umask command
I tried to recognize the wake word
I tried to classify text using TensorFlow
I tried to estimate the pi stochastically
I tried to touch the COTOHA API
I tried using the BigQuery Storage API
I tried to predict Covid-19 using Darts
I tried to transform the face image using sparse_image_warp of TensorFlow Addons
I tried to execute SQL from the local environment using Looker SDK
I tried to get the batting results of Hachinai using image processing
I tried to control multiple servo motors MG996R using the servo driver PCA9685.
I tried to summarize various sentences using the automatic summarization API "summpy"
I tried to extract and illustrate the stage of the story using COTOHA
I tried the common story of using Deep Learning to predict the Nikkei 225
I tried to create a sample to access Salesforce using Python and Bottle
I tried to analyze the New Year's card by myself using python
I tried web scraping to analyze the lyrics.
I tried using scrapy for the first time
Log in to the remote server with SSH
vprof --I tried using the profiler for Python
Setting to output the log of cron execution
I tried to optimize while drying the laundry
I tried to save the data with discord
I tried to synthesize WAV files using Pydub.
I tried using the Google Cloud Vision API
I tried to touch the API of ebay
I tried to correct the keystone of the image
I tried to output LLVM IR with Python
I tried using the Datetime module by Python
Try to create an HTTP server using Node.js
Qiita Job I tried to analyze the job offer
I tried using firebase for Django's cache server
[Python] I will upload the FTP to the FTP server.
I tried using the image filter of OpenCV
LeetCode I tried to summarize the simple ones
I tried using the functional programming library toolz
I tried to implement the traveling salesman problem
I tried to make a ○ ✕ game using TensorFlow
I tried to deliver mail from Node.js and Python using the mail delivery service (SendGrid) of IBM Cloud!
I tried to predict the price of ETF
I tried to vectorize the lyrics of Hinatazaka46!
I tried to predict the deterioration of the lithium ion battery using the Qore SDK
I tried to notify the update of "Hamelin" using "Beautiful Soup" and "IFTTT"
[Python] I tried to judge the member image of the idol group using Keras
When I tried to change the root password with ansible, I couldn't access it.