I think the equation you want is p=5-logx. If you use lnx, then for x=5000, p≈-3.5, which doesn't make sense.
With logx, p≈1.3, which is more realistic.
First we need to write x as the subject. The vendor will be changing p, so that needs to be the thing that you can use to work out x, rather than the other way around.
Switch logx and p: logx = 5-p
Take to powers of 10: x = 10^(5-p)
The number of customers per day he gets is 10^(5-p) and the profit per slice sold is p-1, because he pays $1 for each slice.
Therefore, his total profit per day is (p-1)(10^(5-p)).
To work out the optimum value of p, this expression must be differentiated and then equated to 0.
The expression is complicated, so differentiating it will be tough. The (p-1) part is easy, that just differentiates to 1. The 10^(5-p) part is tougher.
Using the chain rule of differentiation (dy/dt * dt/dx = dy/dx) and substituting t = 5-p will help.
The differential of 10^t is 10^t * ln 10 and the differential of 5-p is -1, so multiplying these together gives the differential of 10^(5-p) = -(10^t * ln 10), or -(10^(5-p) * ln 10)
The product rule of differentiation says that (uv)' = uv' + vu'.
Applying that to this gives your total differential to be -(p-1)(10^(5-p))(ln 10) + 10^(5-p)
This simplifies to 10^(5-p) * (-(p-1)(ln 10) + 1).
As this term has to equal 0 for p to be optimum, one of the terms that have been multiplied to give this term has to equal 0. 10^(5-p) is always positive and can never equal 0, so that leaves -(p-1)(ln 10) + 1 = 0
Shift the terms to opposite sides: (p-1)(ln 10) = 1
Divide by ln 10: p-1 = 1/ln 10
Add 1: p = 1 + 1/ln 10 ≈ $1.43, to the nearest cent.
...That would be the optimum price, but it would only attract 3679 customers, so it can't be used. It looks like the optimum price that fits your specifications is when x = 5000, which makes the price $1.30 to the nearest cent. That might have something to do with me guessing the right equation though. I don't know what it's supposed to be, all I know is that yours doesn't work.
Hopefully, you'll be able to find the right equation and use my working as a 'template' so you can solve it yourself.