The invention provides a log
processing method and device for memory optimization, equipment and a medium, the method is applied to the technical field of log
processing, and the method comprises the steps that a container management platform starts a main application container and a collection container, and mounts a shared storage volume to a predetermined
directory of the main application container and the collection container; the collection container reads an
environment variable to obtain a socket path, creates a
Unix domain socket file in the shared storage volume and monitors the
Unix domain socket file; the main application container creates a
symbolic link from the
system log interface to the socket file through the life cycle hook;
log data output by the application program is redirected to the
Unix domain socket through a
symbolic link; and the collection container receives the log and writes the log into an annular buffer area, in-situ analysis is carried out in the buffer area to generate a structured log character string, and the structured log character string is packaged into a
JSON format to be output to a standard output interface. According to the method, the
log data can be subjected to in-situ analysis through
multiplexing of the annular buffer area, so that
resource consumption of the buffer area is reduced, and frequent data
copying is reduced.