teratail header banner
teratail header banner
質問するログイン新規登録

質問編集履歴

3

追記

2019/04/19 04:43

投稿

gogoackman3
gogoackman3

スコア109

title CHANGED
File without changes
body CHANGED
@@ -78,4 +78,212 @@
78
78
 
79
79
  #お願い
80
80
 
81
- もしpumaのログローテーション方法がわかる方がいれば教えて頂けると嬉しいです。
81
+ もしpumaのログローテーション方法がわかる方がいれば教えて頂けると嬉しいです。
82
+
83
+ #追記
84
+ 回答頂いた内容を踏まえ以下の通り実装し、24時間が経過し日付が変わったので、ローテーションされているか確認しました。
85
+
86
+
87
+ `/etc/logrotate.d/puma`の実装内容
88
+
89
+ ```ここに言語を入力
90
+ /var/log/puma/*log {
91
+ daily
92
+ missingok
93
+ rotate 5
94
+ ifempty
95
+ copytruncate
96
+ compress
97
+ delaycompress
98
+ create 0644 root root
99
+ su root root
100
+ }
101
+ ```
102
+ 結果としてはローテーションされていませんでした。。ファイルはアクセスログとエラーログがそれぞれ一つある状態のままです。
103
+
104
+ ```ここに言語を入力
105
+ ➜ puma pwd
106
+ /var/log/puma
107
+ ➜ puma ls
108
+ puma.stderr.log puma.stdout.log
109
+ ➜ puma ls -l
110
+ 合計 452
111
+ -rw-r--r-- 1 root root 222256 4月 19 03:22 puma.stderr.log
112
+ -rw-r--r-- 1 root root 228936 4月 19 04:20 puma.stdout.log
113
+ ```
114
+
115
+ 以下の通り、ステータスを確認すると、puma.stdout.logとpuma.stderr.logは4/19になっています。実装したのは4/18なので、ローテーションされている??ということでしょうか?
116
+
117
+ ```ここに言語を入力
118
+ ➜ /etc cat /var/lib/logrotate.status
119
+ logrotate state -- version 2
120
+ "/var/log/nginx/error.log" 2019-4-19
121
+ "/var/log/yum.log" 2019-4-18
122
+ "/var/log/redis/redis.log" 2019-4-14
123
+ "/var/log/dracut.log" 2017-3-24
124
+ "/var/log/puma/puma.stdout.log" 2019-4-19
125
+ "/var/lib/mysql/mysqld.log" 2017-3-25
126
+ "/var/log/monit" 2019-4-19
127
+ "/var/log/wtmp" 2017-3-24
128
+ "/var/log/spooler" 2019-4-14
129
+ "/var/log/puma/puma.stderr.log" 2019-4-19
130
+ "/var/log/btmp" 2019-4-1
131
+ "/var/log/maillog" 2019-4-14
132
+ "/var/log/secure" 2019-4-14
133
+ "/var/log/nginx/access.log" 2019-4-19
134
+ "/var/log/messages" 2019-4-14
135
+ "/var/account/pacct" 2017-3-24
136
+ "/var/log/cron" 2019-4-14
137
+ ```
138
+
139
+ 参考までに`/etc/logrotate.conf`は以下の通りです。
140
+
141
+ ```
142
+ ➜ sudo cat /etc/logrotate.conf
143
+ # see "man logrotate" for details
144
+ # rotate log files weekly
145
+ weekly
146
+
147
+ # keep 4 weeks worth of backlogs
148
+ rotate 4
149
+
150
+ # create new (empty) log files after rotating old ones
151
+ create
152
+
153
+ # use date as a suffix of the rotated file
154
+ dateext
155
+
156
+ # uncomment this if you want your log files compressed
157
+ #compress
158
+
159
+ # RPM packages drop log rotation information into this directory
160
+ include /etc/logrotate.d
161
+
162
+ # no packages own wtmp and btmp -- we'll rotate them here
163
+ /var/log/wtmp {
164
+ monthly
165
+ create 0664 root utmp
166
+ minsize 1M
167
+ rotate 1
168
+ }
169
+
170
+ /var/log/btmp {
171
+ missingok
172
+ monthly
173
+ create 0600 root utmp
174
+ rotate 1
175
+ }
176
+
177
+ # system-specific logs may be also be configured here.
178
+ ```
179
+
180
+
181
+ また[この記事](https://open-groove.net/linux/logrotate-test/)を参考に`/usr/sbin/logrotate -dv /etc/logrotate.conf`を実行すると結果は以下の通りでした。
182
+
183
+ ```ここに言語を入力
184
+ ➜ /usr/sbin/logrotate -dv /etc/logrotate.conf
185
+ reading config file /etc/logrotate.conf
186
+ including /etc/logrotate.d
187
+ Ignoring nginx.rpmnew, because of .rpmnew ending
188
+ reading config file dracut
189
+ reading config info for /var/log/dracut.log
190
+ reading config file monit
191
+ reading config info for /var/log/monit
192
+ reading config file mysql
193
+ reading config file nginx
194
+ reading config info for /var/log/nginx/*log
195
+ reading config file psacct
196
+ reading config info for /var/account/pacct
197
+ reading config file puma
198
+ reading config info for /var/log/puma/*log
199
+ error: puma:11 unknown option 'su' -- ignoring line
200
+ error: puma:11 unexpected text
201
+ reading config file redis
202
+ reading config info for /var/log/redis/redis.log
203
+ reading config file syslog
204
+ reading config info for /var/log/cron
205
+ /var/log/maillog
206
+ /var/log/messages
207
+ /var/log/secure
208
+ /var/log/spooler
209
+
210
+ reading config file yum
211
+ reading config info for /var/log/yum.log
212
+ reading config info for /var/log/wtmp
213
+ reading config info for /var/log/btmp
214
+
215
+ Handling 10 logs
216
+
217
+ rotating pattern: /var/log/dracut.log 1048576 bytes (4 rotations)
218
+ empty log files are not rotated, old logs are removed
219
+ considering log /var/log/dracut.log
220
+ log does not need rotating
221
+
222
+ rotating pattern: /var/log/monit 102400 bytes (4 rotations)
223
+ empty log files are not rotated, old logs are removed
224
+ considering log /var/log/monit
225
+ log does not need rotating
226
+ not running postrotate script, since no logs were rotated
227
+
228
+ rotating pattern: /var/log/nginx/*log after 1 days (52 rotations)
229
+ empty log files are not rotated, old logs are removed
230
+ considering log /var/log/nginx/access.log
231
+ log does not need rotating
232
+ considering log /var/log/nginx/error.log
233
+ log does not need rotating
234
+ not running postrotate script, since no logs were rotated
235
+
236
+ rotating pattern: /var/account/pacct after 1 days (31 rotations)
237
+ empty log files are not rotated, old logs are removed
238
+ considering log /var/account/pacct
239
+ log does not need rotating
240
+ not running postrotate script, since no logs were rotated
241
+
242
+ rotating pattern: /var/log/puma/*log after 1 days (5 rotations)
243
+ empty log files are rotated, old logs are removed
244
+ considering log /var/log/puma/puma.stderr.log
245
+ log does not need rotating
246
+ considering log /var/log/puma/puma.stdout.log
247
+ log does not need rotating
248
+
249
+ rotating pattern: /var/log/redis/redis.log weekly (10 rotations)
250
+ empty log files are not rotated, old logs are removed
251
+ considering log /var/log/redis/redis.log
252
+ log does not need rotating
253
+
254
+ rotating pattern: /var/log/cron
255
+ /var/log/maillog
256
+ /var/log/messages
257
+ /var/log/secure
258
+ /var/log/spooler
259
+ weekly (4 rotations)
260
+ empty log files are rotated, old logs are removed
261
+ considering log /var/log/cron
262
+ log does not need rotating
263
+ considering log /var/log/maillog
264
+ log does not need rotating
265
+ considering log /var/log/messages
266
+ log does not need rotating
267
+ considering log /var/log/secure
268
+ log does not need rotating
269
+ considering log /var/log/spooler
270
+ log does not need rotating
271
+ not running postrotate script, since no logs were rotated
272
+
273
+ rotating pattern: /var/log/yum.log yearly (4 rotations)
274
+ empty log files are not rotated, old logs are removed
275
+ considering log /var/log/yum.log
276
+ log does not need rotating
277
+
278
+ rotating pattern: /var/log/wtmp monthly (1 rotations)
279
+ empty log files are rotated, only log files >= 1048576 bytes are rotated, old logs are removed
280
+ considering log /var/log/wtmp
281
+ log does not need rotating
282
+
283
+ rotating pattern: /var/log/btmp monthly (1 rotations)
284
+ empty log files are rotated, old logs are removed
285
+ considering log /var/log/btmp
286
+ log does not need rotating
287
+ ```
288
+
289
+ `/var/log/puma`の中にあるpuma.stdout.logとpuma.stderr.logの2ファイルはローテーションされているのでしょうか?おそらくされていないと思われるのですが、何か作成したファイルに問題がありますでしょうか?

2

誤字

2019/04/19 04:43

投稿

gogoackman3
gogoackman3

スコア109

title CHANGED
File without changes
body CHANGED
@@ -42,8 +42,8 @@
42
42
 
43
43
  ```
44
44
  config.logger = Logger.new("log/production.log", 5, 10 * 1024 * 1024)
45
- config.logger = Logger.new("/var/log//puma/puma.stdout.log", 5, 10 * 1024 * 1024)
45
+ config.logger = Logger.new("/var/log/puma/puma.stdout.log", 5, 10 * 1024 * 1024)
46
- config.logger = Logger.new("/var/log//puma/puma.stderr.log", 5, 10 * 1024 * 1024)
46
+ config.logger = Logger.new("/var/log/puma/puma.stderr.log", 5, 10 * 1024 * 1024)
47
47
  ```
48
48
 
49
49
  #pumaのlogrotate案2

1

誤字の修正

2019/04/18 03:44

投稿

gogoackman3
gogoackman3

スコア109

title CHANGED
File without changes
body CHANGED
@@ -3,7 +3,7 @@
3
3
 
4
4
  ※puma.rbでのログ出力設定は以下の通りです。↓
5
5
  ```
6
- stdout_redirect "var/log/puma/puma.stdout.log", "var/log/puma/puma.stderr.log", true
6
+ stdout_redirect "/var/log/puma/puma.stdout.log", "/var/log/puma/puma.stderr.log", true
7
7
  ```
8
8
  #####nginxのログローテーション設定
9
9