how to use papertrail (send logs) in nest js? - node.js

is there any way to use papertrail in nestjs application ? I am added loggers like this
https://docs.nestjs.com/techniques/logger
Now I want to send this logs to papertrail.. is there any way to send ?
I got the example of nodejs . but I didn't find any example of nestjs

You could send it to SQL or NoSQL. Eventually, you want to store a log record.
Or you could save it on your local server by creating your own log file.

Related

Getting realtime notification whenever a new friend request is received MERN Stack using Socket.io

I am trying to add a functionality in my web app where whenever a new friend request is received in the database (mongodb) then i get a notification through from backend (Node.js) to my frontend (React.js)
Now i researched about this functionality and get to know about socket.io but the problem is the solutions i found which were using socket.io were kind of a brute force according to me ,
In those solutions they were querying the database inside the socket.emit(),
Now according to me if I keep querying the database every 4-5 seconds is it a good approach to do that doesn't it put load on database?
What is the right way to do this?
What i have tried so far is finding a better solution than querying the database again and again till i get an update. But i had no luck ..
The best approach is to connect frontend with backend using websocket/socket.io and as soon as you add a new object the server should push the data to frontend. You don't have to run a database query every 4-5 second. Write a server push event in your data.save() function. So as soon as you create a new object, the backend sends data to frontend.

Nextjs Mongodb stream data on a serverless app

I am using these guides to create my Next-Mongo app without a NodeJS server:
https://www.mongodb.com/developer/how-to/nextjs-with-mongodb/
https://www.section.io/engineering-education/build-nextjs-with-mongodb-and-deploy-on-vercel/#setting-up-the-api-route
I couldn't find the answer to this but is it possible to stream data? The closest solution I have to making the ap look real-time is either refreshing the page or getting back the published data on the response (which I can just append to the state) - this however is very limited.
I have used libraries like Pusher in the past with an express app but I can't use that on my serveless app.
It sounds to me you want to watch and consume on the front end collection changes from your mongodb!? If so, I'd try ably for real-time communication.
You can use ably in your model to broadcast the data you want to render real-time. You could also use pusher to accomplish the same result.
https://mongoosejs.com/docs/change-streams.html

How to configure Angular app with ELK stack

I want to configure my Angular app with ELK stack.
Option 1:send from Angular an http post request to logstash.
Option 2: send from Angular an http post request to node.js server, and that server will send the messages to logstash.
Maybe there are another options, but i dont know. I didnt find any tutorials about it.
What is right way to do that?
Create a usable API with either REST or GraphQL or other (gRPC up to you really) to connect the client with the server, it is the most complete technique for anything wholesome.
From there you can then add more features to it and have a seed project for the future aswell.
Technically the Client sends a query to the API of your choice then the API talks with the server that the logic dictates (this can be elasticsearch / express / or any other) and then it either logs data on elastic or the DB or any other.

Sending Python App logs directly to SOLR

I am currently using python logging with file handler to write the logs. However, was wondering if there is a way to send logs straight to an external system such as SOLR? I see there is a way of sending it to logstash, however would prefer if I could send it straight to SOLR. Is there any way to do that?

Socket.io - Easiest way to log values from the server

When you are testing your javascript on the server (server.js) file using socket.io, you can't use console.log(), or alert().
What is the easiest way to log or alert a value for testing purposes?
Of course you can use console.log
It just gets logged to the terminal.
Node Docs on console
I log to syslog via the node-syslog package that way I can still see the logs even when the server is running in the background.

Resources