yeonghoon.kim

  • 게시판
  • 갤러리

logger - 커스텀 로그 찍기

김영훈 2019.11.28 15:34 조회 수 : 619

1. 사용법

Usage:
 logger [options] [<message>]

Enter messages into the system log.

Options:
 -i                       log the logger command's PID
     --id[=<id>]          log the given <id>, or otherwise the PID
 -f, --file <file>        log the contents of this file
 -e, --skip-empty         do not log empty lines when processing files
     --no-act             do everything except the write the log
 -p, --priority <prio>    mark given message with this priority
     --octet-count        use rfc6587 octet counting
     --prio-prefix        look for a prefix on every line read from stdin
 -s, --stderr             output message to standard error as well
 -S, --size <size>        maximum size for a single message
 -t, --tag <tag>          mark every line with this tag
 -n, --server <name>      write to this remote syslog server
 -P, --port <port>        use this port for UDP or TCP connection
 -T, --tcp                use TCP only
 -d, --udp                use UDP only
     --rfc3164            use the obsolete BSD syslog protocol
     --rfc5424[=<snip>]   use the syslog protocol (the default for remote);
                            <snip> can be notime, or notq, and/or nohost
     --sd-id <id>         rfc5424 structured data ID
     --sd-param <data>    rfc5424 structured data name=value
     --msgid <msgid>      set rfc5424 message id field
 -u, --socket <socket>    write to this Unix socket
     --socket-errors[=<on|off|auto>]
                          print connection errors when using Unix sockets
     --journald[=<file>]  write journald entry

 -h, --help               display this help
 -V, --version            display version

For more details see logger(1).


2. 사용 예시

#!/bin/bash

HELLO_ROOT=$(echo "[ $( hostname -I )] $(date '+%Y-%m-%d %H:%M:%S') ROOT_LOGIN - $(w | awk '{ print $3 }' | tail -n 1)")
CONNECT_USER=$(w | grep pts | wc -l)

if [ "${CONNECT_USER}" -ge 1 ]
then
    logger -p local6.notice -t HELLO_ROOT ${HELLO_ROOT}
fi


3. 적용 확인(/var/log/messsage)

Nov 28 14:17:41 localhost HELLO_ROOT[5436]: [ 10.101.0.10 ] 2019-11-28 14:17:41 ROOT_LOGIN - xxx.xxx.xxx.xxx  

  • 추천 0

  • 비추천 0
이 게시물을
목록

댓글 0

번호 제목 글쓴이 날짜 조회 수
139 학원 20200528 정리(페이징) 김영훈 2020.05.28 1373
138 학원 20200527 정리(스프링 DAO) 김영훈 2020.05.27 1060
137 학원 20200526 정리(스프링 RequestParam, DI, Maven) 김영훈 2020.05.26 2138
136 학원 20200525 정리(JSP, 스프링 기초, MVC패턴) 김영훈 2020.05.25 816
135 학원 20200513 정리(jQuery 기초2) 김영훈 2020.05.13 1238
134 학원 20200512 정리(jQuery 기초1) 김영훈 2020.05.12 970
133 학원 20200511 정리(javascript 기초3) 김영훈 2020.05.11 1472
132 학원 20200506 정리(javascript 기초2) 김영훈 2020.05.06 1027
131 1부터 1000까지 출력(라인 수 = 최대 출력 개수) 김영훈 2020.05.04 543
130 학원 20200428 정리(javascript 기초1) 김영훈 2020.04.28 2794
129 학원 20200424 정리(CSS 기초3) 김영훈 2020.04.24 661
128 학원 20200423 정리(CSS 기초2) 김영훈 2020.04.23 1499
127 학원 20200422 정리(CSS 기초1) 김영훈 2020.04.22 2349
126 학원 20200421 정리(HTML 링크, 테이블, 영역) 김영훈 2020.04.21 1054
125 학원 20200420 정리(HTML 기초) 김영훈 2020.04.20 1993
124 학원 20200416 정리(DB 설계) 김영훈 2020.04.16 982
123 학원 20200414 쿼리 연습 김영훈 2020.04.14 665
122 학원 20200413 정리(INSERT, UPDATE, DELETE, DDL, SEQUENCE) 김영훈 2020.04.13 696
121 학원 20200409 정리(UNION, DISTINCT, ROW_NUMBER, RANK) 김영훈 2020.04.09 1021
120 학원 20200403 정리(SELECT 조인, 쿼리 연습) 김영훈 2020.04.03 620
쓰기 태그
 첫 페이지 6 7 8 9 10 11 12 13 14 15 끝 페이지