yeonghoon.kim

  • 게시판
  • 갤러리
  • aws

logger - 커스텀 로그 찍기

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

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

사진 및 파일 첨부

여기에 파일을 끌어 놓거나 왼쪽의 버튼을 클릭하세요.

파일 용량 제한 : 0MB (허용 확장자 : *.*)

업로드 중... (0%)

0개 첨부 됨 ( / )
 
번호 제목 글쓴이 날짜 조회 수
공지 2025 일본 여행 계획 김영훈 2024.10.10 986
공지 현금, 저축, 투자, 지출, 예산, 보험 내역(2024-05-30) 김영훈 2024.03.10 639
65 여수/순천 여행 요약(20200120~20200121) 김영훈 2020.01.17 263
64 제주 여행 요약(20200114~20200116) 김영훈 2020.01.17 287
63 제주 여행 요약(20200107~20200109) 김영훈 2020.01.09 300
62 리눅스민트(우분투) rc.local 활성화 김영훈 2020.01.06 294
61 한글2010SE+ 업데이트 불가능한 현상 김영훈 2020.01.02 166
60 제주 여행 요약(20191220~20191223) 김영훈 2019.12.24 200
» logger - 커스텀 로그 찍기 김영훈 2019.11.28 262
58 centos8 ncdu 설치(source) 김영훈 2019.11.28 291
57 엑셀 취소선 단축키 - Ctrl+5 김영훈 2019.11.21 135
56 svn 인증 시 yes를 입력해도 다시 물을 경우 김영훈 2019.11.20 474
55 smtp ip 차단 스크립트 김영훈 2019.11.19 150
54 dovecot imaps(993) 비활성화 김영훈 2019.11.18 242
53 메일서버 SSL 적용(sendmail, dovecot) 김영훈 2019.11.18 272
52 ls 시간 표시 지정 김영훈 2019.11.18 189
51 nginx 설정에서 특정 User-Agent 차단 김영훈 2019.11.15 399
50 ansible 파일 배포 후 크론 등록.yml 김영훈 2019.11.15 159
49 sendmail 버전 숨기기 김영훈 2019.11.14 279
48 sendmail 스팸 리스트에 올라간 것 해제 - stat=Deferred: 421 Your ip is filtered by RBL.(IP:xxx.xxx.xxx.51)(Caues:https://www.spamhaus.org/query/ip/xxx.xxx.xxx.51) 김영훈 2019.11.14 256
47 sendmail 메일 발송 확인 스크립트 김영훈 2019.11.13 212
46 이온큐브 디코더 - https://easytoyou.eu 김영훈 2019.11.10 317
쓰기 태그
 첫 페이지 5 6 7 8 9 10 11 12 13 14 끝 페이지